-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Support semantic highlights for JS files #43992
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
Conversation
…t if we have a valid source file
…ic classification results
| const request = this.processRequest<protocol.EncodedSemanticClassificationsRequest>(protocol.CommandTypes.EncodedSemanticClassificationsFull, { file, start: span.start, length: span.length, format }); | ||
| const r = this.processResponse<protocol.EncodedSemanticClassificationsResponse>(request); | ||
| return r.body!; | ||
| } |
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 is the actual call which vscode uses, so I've replicated that codepath for the server tests. The non-encoded versions of the APIs aren't in the server, and it doesn't feel right to add them just for a test.
| if (actual.spans.length !== expected) { | ||
| this.raiseError(`encodedSemanticClassificationsLength failed - expected total spans to be ${expected} got ${actual.spans.length}`); | ||
| } | ||
| } |
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.
So I can use the 'encoded' classifications routes in the server
src/services/services.ts
Outdated
| if (!isTsOrTsxFile(fileName)) { | ||
| synchronizeHostData(); | ||
| const sourceFile = program && program.getSourceFile(fileName); | ||
| if (!sourceFile) { |
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.
moves synchronizeHostData to the start of the function, then checks for the program and sourceFile. Only potential behavior change is that getValidSourceFile would previously have thrown when there is no source file and now it would return empty results.
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 think we should still keep getValidSourceFile as calling this on wrong LS is still 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.
Sure thing, done!
|
|
||
| // This test validates that an arbitrary JS file gets | ||
| // encoded semantic classifications when requested | ||
| verify.encodedSemanticClassificationsLength("2020", 9) |
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 above test is moved to the server subfolder, where it now goes through the same codepaths as vscode would
sheetalkamat
left a comment
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 think we should still keep getValidSourceFile call.. Other change of removing if statement that checks not TS is correct
Fixes #43350 by allowing checking for the existence of a source file instead of limiting via filename.