@@ -38,6 +38,7 @@ open FsAutoComplete.Lsp
3838open FsAutoComplete.Lsp .Helpers
3939open FSharp.Compiler .Syntax
4040open 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