Skip to content

Commit d38bee2

Browse files
authored
Update FSharp.Analyzers.SDK and Ionide.Analyzers to version 0.32.0 and 0.14.6 respectively; refactor commands to accommodate new project options in analyzer functions. (#1379)
1 parent a8a3a9a commit d38bee2

File tree

5 files changed

+32
-13
lines changed

5 files changed

+32
-13
lines changed

.config/dotnet-tools.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"rollForward": false
2525
},
2626
"fsharp-analyzers": {
27-
"version": "0.31.0",
27+
"version": "0.32.0",
2828
"commands": [
2929
"fsharp-analyzers"
3030
],

paket.dependencies

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ storage: none
1111
nuget BenchmarkDotNet
1212
nuget Fantomas.Client >= 0.9
1313
nuget FSharp.Compiler.Service >= 43.9.300
14-
nuget Ionide.Analyzers 0.14.5
14+
nuget Ionide.Analyzers 0.14.6
1515
nuget FSharp.Analyzers.Build
1616
nuget Ionide.ProjInfo >= 0.71.2
1717
nuget Ionide.ProjInfo.FCS >= 0.71.2
@@ -22,7 +22,7 @@ nuget Microsoft.Build.Utilities.Core >= 17.4 copy_local:false
2222
nuget Microsoft.Build.Tasks.Core >= 17.4 copy_local: false
2323
nuget Nuget.Frameworks >= 6.3 copy_local: false
2424
nuget Microsoft.CodeAnalysis
25-
nuget FSharp.Analyzers.SDK 0.31.0
25+
nuget FSharp.Analyzers.SDK 0.32.0
2626
nuget ICSharpCode.Decompiler
2727
nuget Mono.Cecil >= 0.11.4
2828
nuget FSharpLint.Core

paket.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ NUGET
5050
FParsec (1.1.1) - restriction: || (== net8.0) (== net9.0) (&& (== netstandard2.0) (>= net5.0)) (&& (== netstandard2.1) (>= net5.0))
5151
FSharp.Core (>= 4.3.4)
5252
FSharp.Analyzers.Build (0.3)
53-
FSharp.Analyzers.SDK (0.31)
53+
FSharp.Analyzers.SDK (0.32)
5454
FSharp.Compiler.Service (43.9.300) - restriction: || (== net8.0) (== net9.0) (&& (== netstandard2.0) (>= net8.0)) (&& (== netstandard2.1) (>= net8.0))
5555
FSharp.Core (9.0.300) - restriction: || (== net8.0) (== net9.0) (&& (== netstandard2.0) (>= net8.0)) (&& (== netstandard2.1) (>= net8.0))
5656
McMaster.NETCore.Plugins (>= 1.4) - restriction: || (== net8.0) (== net9.0) (&& (== netstandard2.0) (>= net8.0)) (&& (== netstandard2.1) (>= net8.0))
@@ -124,7 +124,7 @@ NUGET
124124
ICSharpCode.Decompiler (8.2.0.7535)
125125
System.Collections.Immutable (>= 6.0)
126126
System.Reflection.Metadata (>= 6.0)
127-
Ionide.Analyzers (0.14.5)
127+
Ionide.Analyzers (0.14.6)
128128
Ionide.KeepAChangelog.Tasks (0.1.8) - copy_local: true
129129
Ionide.LanguageServerProtocol (0.7)
130130
FSharp.Core (>= 6.0)

src/FsAutoComplete.Core/Commands.fs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ type NotificationEvent =
8787

8888
module Commands =
8989
open System.Collections.Concurrent
90+
open FSharp.Analyzers.SDK
91+
9092
let fantomasLogger = LogProvider.getLoggerByName "Fantomas"
9193
let commandsLogger = LogProvider.getLoggerByName "Commands"
9294

@@ -1147,15 +1149,17 @@ module Commands =
11471149
content: ISourceText,
11481150
pt,
11491151
tast,
1150-
checkFileResults: FSharpCheckFileResults
1152+
checkFileResults: FSharpCheckFileResults,
1153+
projectOptions: AnalyzerProjectOptions
11511154
) =
11521155
let ctx: SDK.EditorContext =
11531156
{ FileName = UMX.untag file
11541157
SourceText = content
11551158
ParseFileResults = pt
11561159
CheckFileResults = Some checkFileResults
11571160
TypedTree = Some tast
1158-
CheckProjectResults = None }
1161+
CheckProjectResults = None
1162+
ProjectOptions = projectOptions }
11591163

11601164
let extractResultsFromAnalyzer (r: SDK.AnalysisResult) =
11611165
match r.Output with

src/FsAutoComplete/LspServers/AdaptiveServerState.fs

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ open FsAutoComplete.Lsp
3838
open FsAutoComplete.Lsp.Helpers
3939
open FSharp.Compiler.Syntax
4040
open FsAutoComplete.ProjectWorkspace
41+
open FSharp.Analyzers.SDK
4142

4243

4344
/// <summary>Handle tracking in-flight ServerProgressReport and allow cancellation of actions if a client decides to.</summary>
@@ -345,7 +346,8 @@ type AdaptiveState
345346
let fileParsed =
346347
Event<FSharpParseFileResults * CompilerProjectOption * CancellationToken>()
347348

348-
let fileChecked = Event<ParseAndCheckResults * VolatileFile * CancellationToken>()
349+
let fileChecked =
350+
Event<CompilerProjectOption * ParseAndCheckResults * VolatileFile * CancellationToken>()
349351

350352
let detectTests (parseResults: FSharpParseFileResults) (proj: CompilerProjectOption) ct =
351353
try
@@ -521,7 +523,12 @@ type AdaptiveState
521523
}
522524

523525

524-
let runAnalyzers (config: FSharpConfig) (parseAndCheck: ParseAndCheckResults) (volatileFile: VolatileFile) =
526+
let runAnalyzers
527+
(config: FSharpConfig)
528+
(parseAndCheck: ParseAndCheckResults)
529+
(volatileFile: VolatileFile)
530+
(options: CompilerProjectOption)
531+
=
525532
asyncEx {
526533
if config.EnableAnalyzers then
527534
let file = volatileFile.FileName
@@ -535,6 +542,13 @@ type AdaptiveState
535542
>> Log.addContextDestructured "file" file
536543
)
537544

545+
let analyzerOptions =
546+
match options with
547+
| CompilerProjectOption.BackgroundCompiler po -> AnalyzerProjectOptions.BackgroundCompilerOptions po
548+
| CompilerProjectOption.TransparentCompiler po -> AnalyzerProjectOptions.TransparentCompilerOptions po
549+
550+
551+
538552
match parseAndCheck.GetCheckResults.ImplementationFile with
539553
| Some tast ->
540554
// Since analyzers are not async, we need to switch to a new thread to not block threadpool
@@ -547,7 +561,8 @@ type AdaptiveState
547561
volatileFile.Source,
548562
parseAndCheck.GetParseResults,
549563
tast,
550-
parseAndCheck.GetCheckResults
564+
parseAndCheck.GetCheckResults,
565+
analyzerOptions
551566
)
552567

553568
let! ct = Async.CancellationToken
@@ -565,14 +580,14 @@ type AdaptiveState
565580

566581
do
567582
disposables.Add
568-
<| fileChecked.Publish.Subscribe(fun (parseAndCheck, volatileFile, ct) ->
583+
<| fileChecked.Publish.Subscribe(fun (projectOptions, parseAndCheck, volatileFile, ct) ->
569584
if volatileFile.Source.Length = 0 then
570585
() // Don't analyze and error on an empty file
571586
else
572587
async {
573588
let config = config |> AVal.force
574589
do! builtInCompilerAnalyzers config volatileFile parseAndCheck
575-
do! runAnalyzers config parseAndCheck volatileFile
590+
do! runAnalyzers config parseAndCheck volatileFile projectOptions
576591

577592
}
578593
|> Async.StartWithCT ct)
@@ -1668,7 +1683,7 @@ type AdaptiveState
16681683

16691684

16701685
fileParsed.Trigger(parseAndCheck.GetParseResults, options, ct)
1671-
fileChecked.Trigger(parseAndCheck, file, ct)
1686+
fileChecked.Trigger(options, parseAndCheck, file, ct)
16721687
let checkErrors = parseAndCheck.GetParseResults.Diagnostics
16731688
let parseErrors = parseAndCheck.GetCheckResults.Diagnostics
16741689

0 commit comments

Comments
 (0)