Skip to content

Commit

Permalink
Revert "Revert "Generalize RoamingProfileStorageLocation to ClientSet…
Browse files Browse the repository at this point in the history
…tingsStorageLocation (dotnet#62684)"" (dotnet#62759)

This reverts commit 9c68f9b.
  • Loading branch information
tmat committed Jul 29, 2022
1 parent 5de5410 commit fc02302
Show file tree
Hide file tree
Showing 30 changed files with 186 additions and 470 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected bool TryGetController(EditorCommandArgs args, out Controller controlle
var languageName = args.SubjectBuffer.GetLanguageName();
if (args is not InvokeSignatureHelpCommandArgs &&
languageName != null &&
!_globalOptions.GetOption(SignatureHelpViewOptions.ShowSignatureHelp, languageName))
!_globalOptions.GetOption(SignatureHelpViewOptionsStorage.ShowSignatureHelp, languageName))
{
controller = null;
return false;
Expand Down
20 changes: 0 additions & 20 deletions src/EditorFeatures/Core/Options/NavigationBarViewOptions.cs

This file was deleted.

15 changes: 15 additions & 0 deletions src/EditorFeatures/Core/Options/NavigationBarViewOptionsStorage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using Microsoft.CodeAnalysis.Options;

namespace Microsoft.CodeAnalysis.Editor.Options;

internal sealed class NavigationBarViewOptionsStorage
{
private const string FeatureName = "NavigationBarOptions";

public static readonly PerLanguageOption2<bool> ShowNavigationBar = new(
FeatureName, "ShowNavigationBar", defaultValue: true, new LocalClientSettingsStorageLocation("TextEditor.%LANGUAGE%.Dropdown Bar"));
}
20 changes: 0 additions & 20 deletions src/EditorFeatures/Core/Options/SignatureHelpViewOptions.cs

This file was deleted.

15 changes: 15 additions & 0 deletions src/EditorFeatures/Core/Options/SignatureHelpViewOptionsStorage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using Microsoft.CodeAnalysis.Options;

namespace Microsoft.CodeAnalysis.Editor.Options;

internal sealed class SignatureHelpViewOptionsStorage
{
private const string FeatureName = "SignatureHelpOptions";

public static readonly PerLanguageOption2<bool> ShowSignatureHelp = new(
FeatureName, "ShowSignatureHelp", defaultValue: true, new LocalClientSettingsStorageLocation("TextEditor.%LANGUAGE%.Auto List Params"));
}
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ class C
</Document>, showCompletionInArgumentLists:=showCompletionInArgumentLists)

' disable implicit sig help then type a trigger character -> no session should be available
state.Workspace.GetService(Of IGlobalOptionService).SetGlobalOption(New OptionKey(SignatureHelpViewOptions.ShowSignatureHelp, LanguageNames.CSharp), False)
state.Workspace.GetService(Of IGlobalOptionService).SetGlobalOption(New OptionKey(SignatureHelpViewOptionsStorage.ShowSignatureHelp, LanguageNames.CSharp), False)

state.SendTypeChars("(")
Await state.AssertNoSignatureHelpSession()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ End Class
</Document>)

' disable implicit sig help then type a trigger character -> no session should be available
state.Workspace.GetService(Of IGlobalOptionService).SetGlobalOption(New OptionKey(SignatureHelpViewOptions.ShowSignatureHelp, LanguageNames.VisualBasic), False)
state.Workspace.GetService(Of IGlobalOptionService).SetGlobalOption(New OptionKey(SignatureHelpViewOptionsStorage.ShowSignatureHelp, LanguageNames.VisualBasic), False)
state.SendTypeChars("(")
Await state.AssertNoSignatureHelpSession()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ private async Task AnalyzeDocumentForKindAsync(TextDocument document, AnalysisKi
{
var analysisScope = new DocumentAnalysisScope(document, span: null, nonCachedStateSets.SelectAsArray(s => s.Analyzer), kind);
var executor = new DocumentAnalysisExecutor(analysisScope, compilationWithAnalyzers, _diagnosticAnalyzerRunner, logPerformanceInfo: true, onAnalysisException: OnAnalysisException);
var logTelemetry = GlobalOptions.GetOption(DiagnosticOptions.LogTelemetryForBackgroundAnalyzerExecution);
var logTelemetry = GlobalOptions.GetOption(DiagnosticOptionsStorage.LogTelemetryForBackgroundAnalyzerExecution);
foreach (var stateSet in nonCachedStateSets)
{
var computedData = await ComputeDocumentAnalysisDataAsync(executor, stateSet, logTelemetry, cancellationToken).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,13 @@ public static CompletionOptions GetCompletionOptions(this IGlobalOptionService o
CompletionOptions.Default.SnippetCompletion,
new FeatureFlagStorageLocation("Roslyn.SnippetCompletion"));

// This is serialized by the Visual Studio-specific LanguageSettingsPersister
public static readonly PerLanguageOption2<bool> HideAdvancedMembers = new(nameof(CompletionOptions), nameof(HideAdvancedMembers), CompletionOptions.Default.HideAdvancedMembers);
public static readonly PerLanguageOption2<bool> HideAdvancedMembers = new(
"CompletionOptions", "HideAdvancedMembers", CompletionOptions.Default.HideAdvancedMembers,
new LocalClientSettingsStorageLocation("TextEditor.%LANGUAGE%.Hide Advanced Auto List Members"));

// This is serialized by the Visual Studio-specific LanguageSettingsPersister
public static readonly PerLanguageOption2<bool> TriggerOnTyping = new(nameof(CompletionOptions), nameof(TriggerOnTyping), CompletionOptions.Default.TriggerOnTyping);
public static readonly PerLanguageOption2<bool> TriggerOnTyping = new(
"CompletionOptions", "TriggerOnTyping", CompletionOptions.Default.TriggerOnTyping,
new LocalClientSettingsStorageLocation("TextEditor.%LANGUAGE%.Auto List Members"));

public static readonly PerLanguageOption2<bool> TriggerOnTypingLetters = new(nameof(CompletionOptions), nameof(TriggerOnTypingLetters), CompletionOptions.Default.TriggerOnTypingLetters,
storageLocation: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.TriggerOnTypingLetters"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static DiagnosticMode GetDiagnosticMode(this IGlobalOptionService globalO
// If the workspace diagnostic mode is set to Default, defer to the feature flag service.
if (diagnosticModeOption == DiagnosticMode.Default)
{
return globalOptions.GetOption(DiagnosticOptions.LspPullDiagnosticsFeatureFlag) ? DiagnosticMode.Pull : DiagnosticMode.Push;
return globalOptions.GetOption(DiagnosticOptionsStorage.LspPullDiagnosticsFeatureFlag) ? DiagnosticMode.Pull : DiagnosticMode.Push;
}

// Otherwise, defer to the workspace+option to determine what mode we're in.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Microsoft.CodeAnalysis.Diagnostics
{
internal sealed class DiagnosticOptions
internal sealed class DiagnosticOptionsStorage
{
private const string FeatureName = "DiagnosticOptions";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public async Task TestNoDocumentDiagnosticsForOpenFilesIfDefaultAndFeatureFlagOf
await OpenDocumentAsync(testLspServer, document);

// Ensure we get no diagnostics when feature flag is off.
testLspServer.TestWorkspace.GlobalOptions.SetGlobalOption(new OptionKey(DiagnosticOptions.LspPullDiagnosticsFeatureFlag), false);
testLspServer.TestWorkspace.GlobalOptions.SetGlobalOption(new OptionKey(DiagnosticOptionsStorage.LspPullDiagnosticsFeatureFlag), false);

await Assert.ThrowsAsync<StreamJsonRpc.RemoteInvocationException>(async () => await RunGetDocumentPullDiagnosticsAsync(testLspServer, document.GetURI(), useVSDiagnostics));
}
Expand All @@ -117,7 +117,7 @@ public async Task TestDocumentDiagnosticsForOpenFilesIfDefaultAndFeatureFlagOn(b
var document = testLspServer.GetCurrentSolution().Projects.Single().Documents.Single();
await OpenDocumentAsync(testLspServer, document);

testLspServer.TestWorkspace.GlobalOptions.SetGlobalOption(new OptionKey(DiagnosticOptions.LspPullDiagnosticsFeatureFlag), true);
testLspServer.TestWorkspace.GlobalOptions.SetGlobalOption(new OptionKey(DiagnosticOptionsStorage.LspPullDiagnosticsFeatureFlag), true);

var results = await RunGetDocumentPullDiagnosticsAsync(testLspServer, document.GetURI(), useVSDiagnostics);
Assert.Equal("CS1513", results.Single().Diagnostics.Single().Code);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ private void Enable_pull_diagnostics_experimental_requires_restart_CheckedChange
if (checkboxValue != null)
{
// Update the actual value of the feature flag to ensure CPS is informed of the new feature flag value.
this.OptionStore.SetOption(DiagnosticOptions.LspPullDiagnosticsFeatureFlag, checkboxValue.Value);
this.OptionStore.SetOption(DiagnosticOptionsStorage.LspPullDiagnosticsFeatureFlag, checkboxValue.Value);
}

// Update the workspace option.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ private void SetupView(IVsTextView view)
private void GlobalOptionChanged(object sender, OptionChangedEventArgs e)
{
if (e.Language != _languageService.RoslynLanguageName ||
e.Option != NavigationBarViewOptions.ShowNavigationBar)
e.Option != NavigationBarViewOptionsStorage.ShowNavigationBar)
{
return;
}
Expand Down Expand Up @@ -94,7 +94,7 @@ private void AddOrRemoveDropdown()
return;
}

var enabled = _globalOptions.GetOption(NavigationBarViewOptions.ShowNavigationBar, _languageService.RoslynLanguageName);
var enabled = _globalOptions.GetOption(NavigationBarViewOptionsStorage.ShowNavigationBar, _languageService.RoslynLanguageName);
if (enabled)
{
if (IsOurDropdownBar(dropdownManager, out var existingDropdownBar))
Expand Down
Loading

0 comments on commit fc02302

Please sign in to comment.