-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Expose semantic tokens functionality to Razor EA #72495
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 all commits
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,37 @@ | ||
// 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 System.Collections.Immutable; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Microsoft.CodeAnalysis.Classification; | ||
using Microsoft.CodeAnalysis.LanguageServer.Handler.SemanticTokens; | ||
using Microsoft.CodeAnalysis.Text; | ||
|
||
namespace Microsoft.CodeAnalysis.ExternalAccess.Razor.Cohost.Handlers | ||
{ | ||
internal static class SemanticTokensRange | ||
{ | ||
public static Task<int[]> GetSemanticTokensAsync( | ||
Document document, | ||
ImmutableArray<LinePositionSpan> spans, | ||
bool supportsVisualStudioExtensions, | ||
CancellationToken cancellationToken) | ||
{ | ||
var tokens = SemanticTokensHelpers.HandleRequestHelperAsync( | ||
document, | ||
spans, | ||
supportsVisualStudioExtensions, | ||
ClassificationOptions.Default, | ||
cancellationToken); | ||
|
||
// The above call to get semantic tokens may be inaccurate (because we use frozen partial semantics). Kick | ||
// off a request to ensure that the OOP side gets a fully up to compilation for this project. Once it does | ||
// we can optionally choose to notify our caller to do a refresh if we computed a compilation for a new | ||
// solution snapshot. | ||
// TODO: await semanticTokensRefreshQueue.TryEnqueueRefreshComputationAsync(project, cancellationToken).ConfigureAwait(false); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why was this commented out? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is on the long list of follow-ups. This method is called in the OOP process, so the queue has no access to send a refresh notification back to the client from here. We'll have to expose the queue functionality to the actual endpoint, and handle it there. Razor also has code to intercept refreshes, and map them from the generated C# back to the Razor file, and we need to work out a way to do that (if its still relevant? maybe not for semantic tokens) |
||
return tokens; | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, feels like these tests should be calling the actual range handler..., but thats not a new problem in this PR