Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"rollForward": false
},
"fsharp-analyzers": {
"version": "0.31.0",
"version": "0.32.0",
"commands": [
"fsharp-analyzers"
],
Expand Down
4 changes: 2 additions & 2 deletions paket.dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ storage: none
nuget BenchmarkDotNet
nuget Fantomas.Client >= 0.9
nuget FSharp.Compiler.Service >= 43.9.300
nuget Ionide.Analyzers 0.14.5
nuget Ionide.Analyzers 0.14.6
nuget FSharp.Analyzers.Build
nuget Ionide.ProjInfo >= 0.71.2
nuget Ionide.ProjInfo.FCS >= 0.71.2
Expand All @@ -22,7 +22,7 @@ nuget Microsoft.Build.Utilities.Core >= 17.4 copy_local:false
nuget Microsoft.Build.Tasks.Core >= 17.4 copy_local: false
nuget Nuget.Frameworks >= 6.3 copy_local: false
nuget Microsoft.CodeAnalysis
nuget FSharp.Analyzers.SDK 0.31.0
nuget FSharp.Analyzers.SDK 0.32.0
nuget ICSharpCode.Decompiler
nuget Mono.Cecil >= 0.11.4
nuget FSharpLint.Core
Expand Down
4 changes: 2 additions & 2 deletions paket.lock
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ NUGET
FParsec (1.1.1) - restriction: || (== net8.0) (== net9.0) (&& (== netstandard2.0) (>= net5.0)) (&& (== netstandard2.1) (>= net5.0))
FSharp.Core (>= 4.3.4)
FSharp.Analyzers.Build (0.3)
FSharp.Analyzers.SDK (0.31)
FSharp.Analyzers.SDK (0.32)
FSharp.Compiler.Service (43.9.300) - restriction: || (== net8.0) (== net9.0) (&& (== netstandard2.0) (>= net8.0)) (&& (== netstandard2.1) (>= net8.0))
FSharp.Core (9.0.300) - restriction: || (== net8.0) (== net9.0) (&& (== netstandard2.0) (>= net8.0)) (&& (== netstandard2.1) (>= net8.0))
McMaster.NETCore.Plugins (>= 1.4) - restriction: || (== net8.0) (== net9.0) (&& (== netstandard2.0) (>= net8.0)) (&& (== netstandard2.1) (>= net8.0))
Expand Down Expand Up @@ -124,7 +124,7 @@ NUGET
ICSharpCode.Decompiler (8.2.0.7535)
System.Collections.Immutable (>= 6.0)
System.Reflection.Metadata (>= 6.0)
Ionide.Analyzers (0.14.5)
Ionide.Analyzers (0.14.6)
Ionide.KeepAChangelog.Tasks (0.1.8) - copy_local: true
Ionide.LanguageServerProtocol (0.7)
FSharp.Core (>= 6.0)
Expand Down
8 changes: 6 additions & 2 deletions src/FsAutoComplete.Core/Commands.fs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ type NotificationEvent =

module Commands =
open System.Collections.Concurrent
open FSharp.Analyzers.SDK

let fantomasLogger = LogProvider.getLoggerByName "Fantomas"
let commandsLogger = LogProvider.getLoggerByName "Commands"

Expand Down Expand Up @@ -1147,15 +1149,17 @@ module Commands =
content: ISourceText,
pt,
tast,
checkFileResults: FSharpCheckFileResults
checkFileResults: FSharpCheckFileResults,
projectOptions: AnalyzerProjectOptions
) =
let ctx: SDK.EditorContext =
{ FileName = UMX.untag file
SourceText = content
ParseFileResults = pt
CheckFileResults = Some checkFileResults
TypedTree = Some tast
CheckProjectResults = None }
CheckProjectResults = None
ProjectOptions = projectOptions }

let extractResultsFromAnalyzer (r: SDK.AnalysisResult) =
match r.Output with
Expand Down
27 changes: 21 additions & 6 deletions src/FsAutoComplete/LspServers/AdaptiveServerState.fs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ open FsAutoComplete.Lsp
open FsAutoComplete.Lsp.Helpers
open FSharp.Compiler.Syntax
open FsAutoComplete.ProjectWorkspace
open FSharp.Analyzers.SDK


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

let fileChecked = Event<ParseAndCheckResults * VolatileFile * CancellationToken>()
let fileChecked =
Event<CompilerProjectOption * ParseAndCheckResults * VolatileFile * CancellationToken>()

let detectTests (parseResults: FSharpParseFileResults) (proj: CompilerProjectOption) ct =
try
Expand Down Expand Up @@ -521,7 +523,12 @@ type AdaptiveState
}


let runAnalyzers (config: FSharpConfig) (parseAndCheck: ParseAndCheckResults) (volatileFile: VolatileFile) =
let runAnalyzers
(config: FSharpConfig)
(parseAndCheck: ParseAndCheckResults)
(volatileFile: VolatileFile)
(options: CompilerProjectOption)
=
asyncEx {
if config.EnableAnalyzers then
let file = volatileFile.FileName
Expand All @@ -535,6 +542,13 @@ type AdaptiveState
>> Log.addContextDestructured "file" file
)

let analyzerOptions =
match options with
| CompilerProjectOption.BackgroundCompiler po -> AnalyzerProjectOptions.BackgroundCompilerOptions po
| CompilerProjectOption.TransparentCompiler po -> AnalyzerProjectOptions.TransparentCompilerOptions po



match parseAndCheck.GetCheckResults.ImplementationFile with
| Some tast ->
// Since analyzers are not async, we need to switch to a new thread to not block threadpool
Expand All @@ -547,7 +561,8 @@ type AdaptiveState
volatileFile.Source,
parseAndCheck.GetParseResults,
tast,
parseAndCheck.GetCheckResults
parseAndCheck.GetCheckResults,
analyzerOptions
)

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

do
disposables.Add
<| fileChecked.Publish.Subscribe(fun (parseAndCheck, volatileFile, ct) ->
<| fileChecked.Publish.Subscribe(fun (projectOptions, parseAndCheck, volatileFile, ct) ->
if volatileFile.Source.Length = 0 then
() // Don't analyze and error on an empty file
else
async {
let config = config |> AVal.force
do! builtInCompilerAnalyzers config volatileFile parseAndCheck
do! runAnalyzers config parseAndCheck volatileFile
do! runAnalyzers config parseAndCheck volatileFile projectOptions

}
|> Async.StartWithCT ct)
Expand Down Expand Up @@ -1668,7 +1683,7 @@ type AdaptiveState


fileParsed.Trigger(parseAndCheck.GetParseResults, options, ct)
fileChecked.Trigger(parseAndCheck, file, ct)
fileChecked.Trigger(options, parseAndCheck, file, ct)
let checkErrors = parseAndCheck.GetParseResults.Diagnostics
let parseErrors = parseAndCheck.GetCheckResults.Diagnostics

Expand Down
Loading