-
Notifications
You must be signed in to change notification settings - Fork 417
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
Add SemanticHighlight Endpoint #1734
Conversation
@@ -0,0 +1,6 @@ | |||
namespace OmniSharp.Models.SemanticHighlight | |||
{ | |||
public enum SemanticHighlightModifier |
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.
this doesn't seem to be used?
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.
Although the work isn't planned, we can expect that Rolsyn will introduce a classification API which provides this additional information about classified spans. I wanted the API to reflect it so that consumers could expect it being returned. I could probably process the classifications and return a static modifier...
looks good, thanks for adding this 👍 |
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.
nice, thanks
c379074
to
0e1feff
Compare
@ryanbrandenburg since you own our semantic classification you should take a look at this as well. It will also enable us to call through to Roslyn for semantic colorization as well 😄 |
namespace OmniSharp.Roslyn.CSharp.Services.SemanticHighlight | ||
{ | ||
[OmniSharpHandler(OmniSharpEndpoints.V2.Highlight, LanguageNames.CSharp)] | ||
public class SemanticHighlightService : IRequestHandler<SemanticHighlightRequest, SemanticHighlightResponse> |
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.
Just to clarify, this current impl doesn't take advantage of the partial semantic classification tech that's available right?
Oh and "partial" in the sense of only updating a single lines classification if only that line changed.
I ask because for C# files this might be a huge performance hit.
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.
The highlight request has an optional range property so that only that TextSpan is classified.
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.
I thought VSCode re-requested the entire document pretty frequently though to account for external file changes, project changes etc. Maybe I'm wrong though, my information is coming from design discussions during the features creation; not out of personal trial and error.
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.
Ah, perhaps you are referring to the provideDocumentSemanticTokensEdits
api
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.
Yup exactly!
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.
After thinking about that API for a bit, I'm not sure the Edits api is super useful. It seems mostly to benefit requesting changes from a remote LSP where bandwidth is a concern. It also requires the LSP to hold on to previous state in order to generate the Edits diff as well as fully classify the new state of the document.
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.
I'm not entirely sure how the client interprets all of the data in a response but I imagine it'd also optimize the clients processing of the data
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.
Yeah, I feel like that api would basically be faked by the editor assuming they have a good method of generating the diffs from two sets of SyntaxTokens. Since they already have the before state which the LSP really shouldn't be expected to hold on to.
Implementation of a semantic highlight endpoint. The data that will eventually be returned is different enough from the Highlight endpoint that I thought a new one was justified. This is a simple implementation that supports classification and the static modifier.
As requested in dotnet/vscode-csharp#3565