Skip to content

Commit

Permalink
Access services on Solution rather than Workspace so the code works i…
Browse files Browse the repository at this point in the history
…n Razor cohost scenarios
  • Loading branch information
alexgav committed Oct 17, 2024
1 parent e114b11 commit 761a133
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Features/Core/Portable/Completion/CompletionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ public virtual TextSpan GetDefaultCompletionListSpan(SourceText text, int caretP
if (provider is null)
return CompletionDescription.Empty;

var extensionManager = document.Project.Solution.Workspace.Services.GetRequiredService<IExtensionManager>();
var extensionManager = document.Project.Solution.Services.GetRequiredService<IExtensionManager>();

// We don't need SemanticModel here, just want to make sure it won't get GC'd before CompletionProviders are able to get it.
(document, var semanticModel) = await GetDocumentWithFrozenPartialSemanticsAsync(document, cancellationToken).ConfigureAwait(false);
Expand Down Expand Up @@ -243,7 +243,7 @@ public virtual async Task<CompletionChange> GetChangeAsync(
var provider = GetProvider(item, document.Project);
if (provider != null)
{
var extensionManager = document.Project.Solution.Workspace.Services.GetRequiredService<IExtensionManager>();
var extensionManager = document.Project.Solution.Services.GetRequiredService<IExtensionManager>();

// We don't need SemanticModel here, just want to make sure it won't get GC'd before CompletionProviders are able to get it.
(document, var semanticModel) = await GetDocumentWithFrozenPartialSemanticsAsync(document, cancellationToken).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ ImmutableArray<CompletionProvider> GetTriggeredProviders(
static async Task<ImmutableArray<CompletionProvider>> GetAugmentingProvidersAsync(
Document document, ImmutableArray<CompletionProvider> triggeredProviders, int caretPosition, CompletionTrigger trigger, CompletionOptions options, CancellationToken cancellationToken)
{
var extensionManager = document.Project.Solution.Workspace.Services.GetRequiredService<IExtensionManager>();
var extensionManager = document.Project.Solution.Services.GetRequiredService<IExtensionManager>();
var additionalAugmentingProviders = ArrayBuilder<CompletionProvider>.GetInstance(triggeredProviders.Length);
if (trigger.Kind == CompletionTriggerKind.Insertion)
{
Expand Down Expand Up @@ -327,7 +327,7 @@ private static async Task<CompletionContext> GetContextAsync(
SharedSyntaxContextsWithSpeculativeModel? sharedContext,
CancellationToken cancellationToken)
{
var extensionManager = document.Project.Solution.Workspace.Services.GetRequiredService<IExtensionManager>();
var extensionManager = document.Project.Solution.Services.GetRequiredService<IExtensionManager>();

var context = new CompletionContext(provider, document, position, sharedContext, defaultSpan, triggerInfo, options, cancellationToken);

Expand Down

0 comments on commit 761a133

Please sign in to comment.