Skip to content

Commit 40d789c

Browse files
authored
VS enable diagnostics for unopened files (#15591)
* internalerror with MakeValueAssign fixed? * Add in optional setting for solution-wide background analysis * fix * telementry - lang service started will report background analysis flag
1 parent b4c26d8 commit 40d789c

18 files changed

+176
-17
lines changed

vsintegration/src/FSharp.Editor/LanguageService/LanguageService.fs

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ type internal FSharpWorkspaceServiceFactory [<Composition.ImportingConstructor>]
146146
let captureIdentifiersWhenParsing =
147147
editorOptions.LanguageServicePerformance.CaptureIdentifiersWhenParsing
148148

149+
// Default is false here
150+
let solutionCrawler = editorOptions.Advanced.SolutionBackgroundAnalysis
151+
149152
use _eventDuration =
150153
TelemetryReporter.ReportSingleEventWithDuration(
151154
TelemetryEvents.LanguageServiceStarted,
@@ -163,6 +166,7 @@ type internal FSharpWorkspaceServiceFactory [<Composition.ImportingConstructor>]
163166
nameof enableBackgroundItemKeyStoreAndSemanticClassification,
164167
enableBackgroundItemKeyStoreAndSemanticClassification
165168
nameof captureIdentifiersWhenParsing, captureIdentifiersWhenParsing
169+
nameof solutionCrawler, solutionCrawler
166170
|],
167171
TelemetryThrottlingStrategy.NoThrottling
168172
)
@@ -423,28 +427,23 @@ type internal FSharpLanguageService(package: FSharpPackage) =
423427
override _.Initialize() =
424428
base.Initialize()
425429

426-
let globalOptions =
427-
package
428-
.ComponentModel
429-
.DefaultExportProvider
430-
.GetExport<FSharpGlobalOptions>()
431-
.Value
430+
let exportProvider = package.ComponentModel.DefaultExportProvider
431+
let globalOptions = exportProvider.GetExport<FSharpGlobalOptions>().Value
432432

433-
globalOptions.BlockForCompletionItems <- false
434-
globalOptions.SetBackgroundAnalysisScope(openFilesOnly = true)
433+
let workspace = package.ComponentModel.GetService<VisualStudioWorkspace>()
435434

436-
let globalOptions =
437-
package
438-
.ComponentModel
439-
.DefaultExportProvider
440-
.GetExport<FSharpGlobalOptions>()
441-
.Value
435+
let solutionAnalysis =
436+
workspace
437+
.Services
438+
.GetService<EditorOptions>()
439+
.Advanced
440+
.SolutionBackgroundAnalysis
442441

443-
globalOptions.BlockForCompletionItems <- false
442+
globalOptions.SetBackgroundAnalysisScope(openFilesOnly = not solutionAnalysis)
444443

445-
let theme =
446-
package.ComponentModel.DefaultExportProvider.GetExport<ISetThemeColors>().Value
444+
globalOptions.BlockForCompletionItems <- false
447445

446+
let theme = exportProvider.GetExport<ISetThemeColors>().Value
448447
theme.SetColors()
449448

450449
override _.ContentTypeName = FSharpConstants.FSharpContentTypeName

vsintegration/src/FSharp.Editor/Options/EditorOptions.fs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ type AdvancedOptions =
114114
IsInlineReturnTypeHintsEnabled: bool
115115
IsLiveBuffersEnabled: bool
116116
SendAdditionalTelemetry: bool
117+
SolutionBackgroundAnalysis: bool
117118
}
118119

119120
static member Default =
@@ -125,6 +126,7 @@ type AdvancedOptions =
125126
IsInlineReturnTypeHintsEnabled = false
126127
IsLiveBuffersEnabled = FSharpExperimentalFeaturesEnabledAutomatically
127128
SendAdditionalTelemetry = true
129+
SolutionBackgroundAnalysis = false
128130
}
129131

130132
[<CLIMutable>]

vsintegration/src/FSharp.UIResources/AdvancedOptionsControl.xaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@
4242
<CheckBox x:Name="toggleSendAdditionalTelemetry" IsChecked="{Binding SendAdditionalTelemetry}"
4343
Content="{x:Static local:Strings.Send_Additional_Telemetry}"/>
4444
</GroupBox>
45+
<GroupBox Header="{x:Static local:Strings.Background_analysis}">
46+
<CheckBox x:Name="toggleSolutionBackgroundAnalysis" IsChecked="{Binding SolutionBackgroundAnalysis}"
47+
Content="{x:Static local:Strings.Analyze_full_solution_on_background}"/>
48+
</GroupBox>
4549
</StackPanel>
4650
</ScrollViewer>
4751
</Grid>

vsintegration/src/FSharp.UIResources/Strings.Designer.cs

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vsintegration/src/FSharp.UIResources/Strings.resx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,4 +276,10 @@
276276
<data name="Show_Return_Type_Hints" xml:space="preserve">
277277
<value>Display return type hints (preview)</value>
278278
</data>
279+
<data name="Analyze_full_solution_on_background" xml:space="preserve">
280+
<value>Keep analyzing the entire solution for diagnostics as a low priority background task (requires restart)</value>
281+
</data>
282+
<data name="Background_analysis" xml:space="preserve">
283+
<value>Background analysis</value>
284+
</data>
279285
</root>

vsintegration/src/FSharp.UIResources/xlf/Strings.cs.xlf

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vsintegration/src/FSharp.UIResources/xlf/Strings.de.xlf

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vsintegration/src/FSharp.UIResources/xlf/Strings.es.xlf

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vsintegration/src/FSharp.UIResources/xlf/Strings.fr.xlf

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vsintegration/src/FSharp.UIResources/xlf/Strings.it.xlf

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)