-
Notifications
You must be signed in to change notification settings - Fork 229
Port completion resolve to cohosting #11648
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
Changes from 1 commit
81be24b
c6a8311
3467669
f8e937d
6b61b91
9f24489
6e0206d
587c6a8
50ca664
414e9b0
975e465
611bcb1
c2422c3
2a43837
9d9c657
876a6a0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| // Copyright (c) .NET Foundation. All rights reserved. | ||
| // Licensed under the MIT license. See License.txt in the project root for license information. | ||
|
|
||
| using System.ComponentModel.Composition; | ||
| using Microsoft.CodeAnalysis.Razor.Completion; | ||
|
|
||
| namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost; | ||
|
|
||
| [Export(typeof(CompletionListCache))] | ||
| internal class CohostCompletionListCache : CompletionListCache; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,6 +43,7 @@ internal sealed class CohostDocumentCompletionEndpoint( | |
| SnippetCompletionItemProvider snippetCompletionItemProvider, | ||
| LanguageServerFeatureOptions languageServerFeatureOptions, | ||
| LSPRequestInvoker requestInvoker, | ||
| CompletionListCache completionListCache, | ||
| ILoggerFactory loggerFactory) | ||
| : AbstractRazorCohostDocumentRequestHandler<RoslynCompletionParams, VSInternalCompletionList?>, IDynamicRegistrationProvider | ||
| { | ||
|
|
@@ -52,6 +53,7 @@ internal sealed class CohostDocumentCompletionEndpoint( | |
| private readonly SnippetCompletionItemProvider _snippetCompletionItemProvider = snippetCompletionItemProvider; | ||
| private readonly CompletionTriggerAndCommitCharacters _triggerAndCommitCharacters = new(languageServerFeatureOptions); | ||
| private readonly LSPRequestInvoker _requestInvoker = requestInvoker; | ||
| private readonly CompletionListCache _completionListCache = completionListCache; | ||
| private readonly ILogger _logger = loggerFactory.GetOrCreateLogger<CohostDocumentCompletionEndpoint>(); | ||
|
|
||
| protected override bool MutatesSolutionState => false; | ||
|
|
@@ -211,9 +213,10 @@ public ImmutableArray<Registration> GetRegistrations(VSInternalClientCapabilitie | |
| return null; | ||
| } | ||
|
|
||
| var originalTdi = request.TextDocument; | ||
| request.TextDocument = RoslynLspExtensions.WithUri(request.TextDocument, htmlDocument.Uri); | ||
|
|
||
| _logger.LogDebug($"Resolving auto-insertion edit for {htmlDocument.Uri}"); | ||
| _logger.LogDebug($"Getting completion list for {htmlDocument.Uri} at {request.Position}"); | ||
|
|
||
| var result = await _requestInvoker.ReinvokeRequestOnServerAsync<RoslynCompletionParams, VSInternalCompletionList?>( | ||
| htmlDocument.Buffer, | ||
|
|
@@ -224,6 +227,14 @@ public ImmutableArray<Registration> GetRegistrations(VSInternalClientCapabilitie | |
|
|
||
| var rewrittenResponse = DelegatedCompletionHelper.RewriteHtmlResponse(result?.Response, razorCompletionOptions); | ||
|
|
||
| var completionCapability = _clientCapabilitiesService.ClientCapabilities.TextDocument?.Completion as VSInternalCompletionSetting; | ||
|
|
||
| var textDocument = JsonHelpers.ToVsLSP<TextDocumentIdentifier, RoslynTextDocumentIdentifier>(originalTdi).AssumeNotNull(); | ||
| var razorDocumentIdentifier = new TextDocumentIdentifierAndVersion(textDocument, Version: 0); | ||
|
||
| var resolutionContext = new DelegatedCompletionResolutionContext(razorDocumentIdentifier, RazorLanguageKind.Html, rewrittenResponse.Data); | ||
| var resultId = _completionListCache.Add(rewrittenResponse, resolutionContext); | ||
| rewrittenResponse.SetResultId(resultId, completionCapability); | ||
|
|
||
| return rewrittenResponse; | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.