Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VS enable diagnostics for unopened files #15591

Merged
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ type internal FSharpWorkspaceServiceFactory [<Composition.ImportingConstructor>]
let captureIdentifiersWhenParsing =
editorOptions.LanguageServicePerformance.CaptureIdentifiersWhenParsing

// Default is false here
let solutionCrawler = editorOptions.Advanced.SolutionBackgroundAnalysis

use _eventDuration =
TelemetryReporter.ReportSingleEventWithDuration(
TelemetryEvents.LanguageServiceStarted,
Expand All @@ -163,6 +166,7 @@ type internal FSharpWorkspaceServiceFactory [<Composition.ImportingConstructor>]
nameof enableBackgroundItemKeyStoreAndSemanticClassification,
enableBackgroundItemKeyStoreAndSemanticClassification
nameof captureIdentifiersWhenParsing, captureIdentifiersWhenParsing
nameof solutionCrawler, solutionCrawler
|],
TelemetryThrottlingStrategy.NoThrottling
)
Expand Down Expand Up @@ -423,28 +427,23 @@ type internal FSharpLanguageService(package: FSharpPackage) =
override _.Initialize() =
base.Initialize()

let globalOptions =
package
.ComponentModel
.DefaultExportProvider
.GetExport<FSharpGlobalOptions>()
.Value
let exportProvider = package.ComponentModel.DefaultExportProvider
let globalOptions = exportProvider.GetExport<FSharpGlobalOptions>().Value

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

let globalOptions =
package
.ComponentModel
.DefaultExportProvider
.GetExport<FSharpGlobalOptions>()
.Value
let solutionAnalysis =
workspace
.Services
.GetService<EditorOptions>()
.Advanced
.SolutionBackgroundAnalysis

globalOptions.BlockForCompletionItems <- false
globalOptions.SetBackgroundAnalysisScope(openFilesOnly = not solutionAnalysis)

let theme =
package.ComponentModel.DefaultExportProvider.GetExport<ISetThemeColors>().Value
globalOptions.BlockForCompletionItems <- false

let theme = exportProvider.GetExport<ISetThemeColors>().Value
theme.SetColors()

override _.ContentTypeName = FSharpConstants.FSharpContentTypeName
Expand Down
2 changes: 2 additions & 0 deletions vsintegration/src/FSharp.Editor/Options/EditorOptions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ type AdvancedOptions =
IsInlineReturnTypeHintsEnabled: bool
IsLiveBuffersEnabled: bool
SendAdditionalTelemetry: bool
SolutionBackgroundAnalysis: bool
}

static member Default =
Expand All @@ -125,6 +126,7 @@ type AdvancedOptions =
IsInlineReturnTypeHintsEnabled = false
IsLiveBuffersEnabled = FSharpExperimentalFeaturesEnabledAutomatically
SendAdditionalTelemetry = true
SolutionBackgroundAnalysis = false
}

[<CLIMutable>]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
<CheckBox x:Name="toggleSendAdditionalTelemetry" IsChecked="{Binding SendAdditionalTelemetry}"
Content="{x:Static local:Strings.Send_Additional_Telemetry}"/>
</GroupBox>
<GroupBox Header="{x:Static local:Strings.Background_analysis}">
<CheckBox x:Name="toggleSolutionBackgroundAnalysis" IsChecked="{Binding SolutionBackgroundAnalysis}"
Content="{x:Static local:Strings.Analyze_full_solution_on_background}"/>
</GroupBox>
</StackPanel>
</ScrollViewer>
</Grid>
Expand Down
18 changes: 18 additions & 0 deletions vsintegration/src/FSharp.UIResources/Strings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions vsintegration/src/FSharp.UIResources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -276,4 +276,10 @@
<data name="Show_Return_Type_Hints" xml:space="preserve">
<value>Display return type hints (preview)</value>
</data>
<data name="Analyze_full_solution_on_background" xml:space="preserve">
<value>Keep analyzing the entire solution for diagnostics as a low priority background task (requires restart)</value>
</data>
<data name="Background_analysis" xml:space="preserve">
<value>Background analysis</value>
</data>
</root>
10 changes: 10 additions & 0 deletions vsintegration/src/FSharp.UIResources/xlf/Strings.cs.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions vsintegration/src/FSharp.UIResources/xlf/Strings.de.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions vsintegration/src/FSharp.UIResources/xlf/Strings.es.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions vsintegration/src/FSharp.UIResources/xlf/Strings.fr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions vsintegration/src/FSharp.UIResources/xlf/Strings.it.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions vsintegration/src/FSharp.UIResources/xlf/Strings.ja.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions vsintegration/src/FSharp.UIResources/xlf/Strings.ko.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions vsintegration/src/FSharp.UIResources/xlf/Strings.pl.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions vsintegration/src/FSharp.UIResources/xlf/Strings.pt-BR.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions vsintegration/src/FSharp.UIResources/xlf/Strings.ru.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions vsintegration/src/FSharp.UIResources/xlf/Strings.tr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions vsintegration/src/FSharp.UIResources/xlf/Strings.zh-Hans.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions vsintegration/src/FSharp.UIResources/xlf/Strings.zh-Hant.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.