-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Expose EncodedSemanticClassificationsRequest in protocol.d.ts #42640
Changes from 4 commits
863f7ea
4a10aee
6d0cee4
f320c77
26a0afd
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 |
---|---|---|
|
@@ -7133,6 +7133,41 @@ declare namespace ts.server.protocol { | |
*/ | ||
body?: string[]; | ||
} | ||
/** | ||
* A request to get encoded semantic classifications for a span in the file | ||
*/ | ||
interface EncodedSemanticClassificationsRequest extends FileRequest { | ||
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. Do we also need to add the response types? We currently have to maintain a copy of them in VS Code: https://github.com/microsoft/vscode/blob/3d500ebd8b4a919e8631e916f417e5c68eb90d3f/extensions/typescript-language-features/src/languageFeatures/semanticTokens.ts#L275 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. Aren’t they in typescript/tsserver .d.ts ? 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. We currently only use 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. Makes sense, added |
||
arguments: EncodedSemanticClassificationsRequestArgs; | ||
} | ||
/** | ||
* Arguments for EncodedSemanticClassificationsRequest request. | ||
*/ | ||
interface EncodedSemanticClassificationsRequestArgs extends FileRequestArgs { | ||
/** | ||
* Start position of the span. | ||
*/ | ||
start: number; | ||
/** | ||
* Length of the span. | ||
*/ | ||
length: number; | ||
/** | ||
* Optional parameter for the semantic highlighting response, if absent it | ||
* defaults to "original". | ||
*/ | ||
format?: "original" | "2020"; | ||
} | ||
/** The response for a EncodedSemanticClassificationsRequest */ | ||
interface EncodedSemanticClassificationsResponse extends Response { | ||
body?: EncodedSemanticClassificationsResponseBody; | ||
} | ||
/** | ||
* Implementation response message. Gives series of text spans depending on the format ar. | ||
*/ | ||
interface EncodedSemanticClassificationsResponseBody { | ||
endOfLineState: EndOfLineState; | ||
spans: ClassifiedSpan[] | number[]; | ||
} | ||
/** | ||
* Arguments in document highlight request; include: filesToSearch, file, | ||
* line, offset. | ||
|
@@ -9155,6 +9190,33 @@ declare namespace ts.server.protocol { | |
ES2020 = "ES2020", | ||
ESNext = "ESNext" | ||
} | ||
enum ClassificationType { | ||
comment = 1, | ||
identifier = 2, | ||
keyword = 3, | ||
numericLiteral = 4, | ||
operator = 5, | ||
stringLiteral = 6, | ||
regularExpressionLiteral = 7, | ||
whiteSpace = 8, | ||
text = 9, | ||
punctuation = 10, | ||
className = 11, | ||
enumName = 12, | ||
interfaceName = 13, | ||
moduleName = 14, | ||
typeParameterName = 15, | ||
typeAliasName = 16, | ||
parameterName = 17, | ||
docCommentTagName = 18, | ||
jsxOpenTagName = 19, | ||
jsxCloseTagName = 20, | ||
jsxSelfClosingTagName = 21, | ||
jsxAttribute = 22, | ||
jsxText = 23, | ||
jsxAttributeStringLiteralValue = 24, | ||
bigintLiteral = 25 | ||
} | ||
} | ||
declare namespace ts.server { | ||
interface ScriptInfoVersion { | ||
|
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 isnt correct. The response currently from
getEncodedSemanticClassifications
returns type asts.Classifications
where spans isnumber[]
.More over you are referencing
ClassifiedSpan
here which is only in services and not in protocol.This doesnt correctly reflect what we return.
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.
Dang, I thought I reverted that, that's what I get for shipping late at night, Running baselines to update now and will double check before I ask for a re-review! Thanks
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.
OK, that looks good until we add some sort of wild syntax like
spans: [...[number, number, ClassificationType][] ]
heh