Skip to content

Commit d1a39e2

Browse files
authored
Remove unnecessary options (#56984)
* Remove ForceRoslynLSPCompletionExperiment * Remove CompletionServiceOptions.UsePartialSemanticForCompletion
1 parent 74003ec commit d1a39e2

File tree

6 files changed

+30
-38
lines changed

6 files changed

+30
-38
lines changed

src/EditorFeatures/Core/Implementation/LanguageServer/Handlers/Completion/CompletionHandler.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,8 @@ public CompletionHandler(
9595
var commitCharactersRuleCache = new Dictionary<ImmutableArray<CharacterSetModificationRule>, string[]>(CommitCharacterArrayComparer.Instance);
9696

9797
// Feature flag to enable the return of TextEdits instead of InsertTexts (will increase payload size).
98-
// We check against the CompletionOption for test purposes only.
9998
Contract.ThrowIfNull(context.Solution);
100-
var returnTextEdits = _globalOptions.GetOption(LspOptions.LspCompletionFeatureFlag) ||
101-
_globalOptions.GetOption(CompletionOptions.ForceRoslynLSPCompletionExperiment, document.Project.Language);
99+
var returnTextEdits = _globalOptions.GetOption(LspOptions.LspCompletionFeatureFlag);
102100

103101
TextSpan? defaultSpan = null;
104102
LSP.Range? defaultRange = null;

src/EditorFeatures/Test2/IntelliSense/CSharpCompletionCommandHandlerTests.vb

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6681,15 +6681,18 @@ namespace NS2
66816681
</Project>
66826682
</Workspace>)
66836683

6684+
Dim document = state.Workspace.CurrentSolution.GetDocument(state.Workspace.Documents.Single(Function(d) d.Name = "C.cs").Id)
6685+
66846686
If populateCache Then
66856687
Dim service = state.Workspace.Services.GetLanguageServices(LanguageNames.CSharp).GetRequiredService(Of ITypeImportCompletionService)()
6686-
Dim document = state.Workspace.CurrentSolution.GetDocument(state.Workspace.Documents.Single(Function(d) d.Name = "C.cs").Id)
66876688
Await service.WarmUpCacheAsync(document.Project, CancellationToken.None)
66886689
End If
66896690

6691+
Dim completionService = CType(document.GetLanguageService(Of CompletionService)(), CompletionServiceWithProviders)
6692+
completionService.GetTestAccessor().SuppressPartialSemantics()
6693+
66906694
Dim workspace = state.Workspace
66916695
workspace.TryApplyChanges(workspace.CurrentSolution.WithOptions(workspace.Options _
6692-
.WithChangedOption(CompletionServiceOptions.UsePartialSemanticForCompletion, False) _
66936696
.WithChangedOption(CompletionOptions.ShowItemsFromUnimportedNamespaces, LanguageNames.CSharp, True)))
66946697

66956698
state.SendInvokeCompletionList()
@@ -6737,15 +6740,18 @@ namespace NS2
67376740
</Project>
67386741
</Workspace>)
67396742

6743+
Dim document = state.Workspace.CurrentSolution.GetDocument(state.Workspace.Documents.Single(Function(d) d.Name = "C.cs").Id)
6744+
67406745
If populateCache Then
6741-
Dim service = state.Workspace.Services.GetLanguageServices(LanguageNames.CSharp).GetRequiredService(Of ITypeImportCompletionService)()
6742-
Dim document = state.Workspace.CurrentSolution.GetDocument(state.Workspace.Documents.Single(Function(d) d.Name = "C.cs").Id)
6746+
Dim importCompletionService = state.Workspace.Services.GetLanguageServices(LanguageNames.CSharp).GetRequiredService(Of ITypeImportCompletionService)()
67436747
Await ExtensionMethodImportCompletionHelper.WarmUpCacheAsync(document, CancellationToken.None)
67446748
End If
67456749

6750+
Dim completionService = CType(document.GetLanguageService(Of CompletionService)(), CompletionServiceWithProviders)
6751+
completionService.GetTestAccessor().SuppressPartialSemantics()
6752+
67466753
Dim workspace = state.Workspace
67476754
workspace.TryApplyChanges(workspace.CurrentSolution.WithOptions(workspace.Options _
6748-
.WithChangedOption(CompletionServiceOptions.UsePartialSemanticForCompletion, False) _
67496755
.WithChangedOption(CompletionServiceOptions.TimeoutInMillisecondsForExtensionMethodImportCompletion, -1) _
67506756
.WithChangedOption(CompletionOptions.ShowItemsFromUnimportedNamespaces, LanguageNames.CSharp, True)))
67516757

src/Features/Core/Portable/Completion/CompletionOptions.cs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -78,20 +78,6 @@ internal static class CompletionOptions
7878
public static readonly PerLanguageOption2<bool?> EnableArgumentCompletionSnippets =
7979
new(nameof(CompletionOptions), nameof(EnableArgumentCompletionSnippets), defaultValue: null,
8080
storageLocation: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.EnableArgumentCompletionSnippets"));
81-
82-
// Test-only options
83-
84-
// This option is associated with the Roslyn.LSP.Completion flag and should be removed once the flag is removed.
85-
// It is intended for testing purposes only.
86-
public static readonly PerLanguageOption2<bool> ForceRoslynLSPCompletionExperiment =
87-
new(nameof(CompletionOptions), nameof(ForceRoslynLSPCompletionExperiment), defaultValue: false,
88-
storageLocation: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.ForceRoslynLSPCompletionExperiment"));
89-
90-
public static IEnumerable<PerLanguageOption2<bool>> GetDev15CompletionOptions()
91-
{
92-
yield return ShowCompletionItemFilters;
93-
yield return HighlightMatchingPortionsOfCompletionListItems;
94-
}
9581
}
9682

9783
internal static class CompletionControllerOptions

src/Features/Core/Portable/Completion/CompletionServiceOptions.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ internal static class CompletionServiceOptions
1414
public static readonly Option2<bool> IsExpandedCompletion
1515
= new(nameof(CompletionServiceOptions), nameof(IsExpandedCompletion), defaultValue: false);
1616

17-
/// <summary>
18-
/// For testing only. Changing the default value in actual product might cause perf issues.
19-
/// </summary>
20-
public static readonly Option2<bool> UsePartialSemanticForCompletion
21-
= new(nameof(CompletionServiceOptions), nameof(UsePartialSemanticForCompletion), defaultValue: true);
22-
2317
/// <summary>
2418
/// Timeout value used for time-boxing completion of unimported extension methods.
2519
/// Value less than 0 means no timebox; value == 0 means immediate timeout (for testing purpose)

src/Features/Core/Portable/Completion/CompletionServiceWithProviders.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ private readonly ConditionalWeakTable<AnalyzerReference, ProjectCompletionProvid
4949

5050
private IEnumerable<Lazy<CompletionProvider, CompletionProviderMetadata>>? _lazyImportedProviders;
5151

52+
/// <summary>
53+
/// Test-only switch.
54+
/// </summary>
55+
private bool _suppressPartialSemantics;
56+
5257
protected CompletionServiceWithProviders(Workspace workspace)
5358
{
5459
_workspace = workspace;
@@ -262,13 +267,12 @@ private ImmutableArray<CompletionProvider> FilterProviders(
262267
/// </summary>
263268
private async Task<(Document document, SemanticModel? semanticModel)> GetDocumentWithFrozenPartialSemanticsAsync(Document document, CancellationToken cancellationToken)
264269
{
265-
var usePartialSemantic = _workspace.Options.GetOption(CompletionServiceOptions.UsePartialSemanticForCompletion);
266-
if (usePartialSemantic)
270+
if (_suppressPartialSemantics)
267271
{
268-
return await document.GetPartialSemanticModelAsync(cancellationToken).ConfigureAwait(false);
272+
return (document, await document.GetRequiredSemanticModelAsync(cancellationToken).ConfigureAwait(false));
269273
}
270274

271-
return (document, await document.GetRequiredSemanticModelAsync(cancellationToken).ConfigureAwait(false));
275+
return await document.GetPartialSemanticModelAsync(cancellationToken).ConfigureAwait(false);
272276
}
273277

274278
private protected async Task<(CompletionList? completionList, bool expandItemsAvailable)> GetCompletionsWithAvailabilityOfExpandedItemsAsync(
@@ -764,6 +768,9 @@ internal Task<CompletionContext> GetContextAsync(
764768
defaultSpan: null,
765769
cancellationToken);
766770
}
771+
772+
public void SuppressPartialSemantics()
773+
=> _completionServiceWithProviders._suppressPartialSemantics = true;
767774
}
768775
}
769776
}

src/Features/LanguageServer/ProtocolUnitTests/Completion/CompletionTests.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
using Microsoft.CodeAnalysis.Completion;
1313
using Microsoft.CodeAnalysis.LanguageServer.Handler;
1414
using Microsoft.CodeAnalysis.LanguageServer.Handler.Completion;
15+
using Microsoft.CodeAnalysis.Options;
1516
using Roslyn.Test.Utilities;
1617
using Xunit;
1718
using LSP = Microsoft.VisualStudio.LanguageServer.Protocol;
@@ -327,8 +328,8 @@ void M()
327328
var document = solution.Projects.First().Documents.First();
328329

329330
// Set to use prototype completion behavior (i.e. feature flag).
330-
var options = solution.Workspace.Options.WithChangedOption(CompletionOptions.ForceRoslynLSPCompletionExperiment, LanguageNames.CSharp, true);
331-
Assert.True(solution.Workspace.TryApplyChanges(solution.WithOptions(options)));
331+
var globalOptions = testLspServer.TestWorkspace.GetService<IGlobalOptionService>();
332+
globalOptions.SetGlobalOption(new OptionKey(LspOptions.LspCompletionFeatureFlag), true);
332333

333334
var textEdit = GenerateTextEdit(@"\\A", startLine: 5, startChar: 19, endLine: 5, endChar: 19);
334335

@@ -364,8 +365,8 @@ void M()
364365
var document = solution.Projects.First().Documents.First();
365366

366367
// Set to use prototype completion behavior (i.e. feature flag).
367-
var options = solution.Workspace.Options.WithChangedOption(CompletionOptions.ForceRoslynLSPCompletionExperiment, LanguageNames.CSharp, true);
368-
Assert.True(solution.Workspace.TryApplyChanges(solution.WithOptions(options)));
368+
var globalOptions = testLspServer.TestWorkspace.GetService<IGlobalOptionService>();
369+
globalOptions.SetGlobalOption(new OptionKey(LspOptions.LspCompletionFeatureFlag), true);
369370

370371
var textEdit = GenerateTextEdit(@"\A", startLine: 5, startChar: 20, endLine: 5, endChar: 21);
371372

@@ -401,8 +402,8 @@ void M()
401402
var document = solution.Projects.First().Documents.First();
402403

403404
// Set to use prototype completion behavior (i.e. feature flag).
404-
var options = solution.Workspace.Options.WithChangedOption(CompletionOptions.ForceRoslynLSPCompletionExperiment, LanguageNames.CSharp, true);
405-
Assert.True(solution.Workspace.TryApplyChanges(solution.WithOptions(options)));
405+
var globalOptions = testLspServer.TestWorkspace.GetService<IGlobalOptionService>();
406+
globalOptions.SetGlobalOption(new OptionKey(LspOptions.LspCompletionFeatureFlag), true);
406407

407408
var textEdit = GenerateTextEdit(@"\\A", startLine: 5, startChar: 23, endLine: 5, endChar: 25);
408409

0 commit comments

Comments
 (0)