Skip to content

Commit acc5fa0

Browse files
author
Orta Therox
authored
Expose EncodedSemanticClassificationsRequest in protocol.d.ts (#42640) (#42965)
* Expose EncodedSemanticClassificationsRequest in protocol.d.ts * Adds the response for encoded semantic highlights too * Update types: * Also include classificationtype anyway * Fix feedback
1 parent 08ad0e2 commit acc5fa0

File tree

2 files changed

+102
-2
lines changed

2 files changed

+102
-2
lines changed

src/server/protocol.ts

+40-2
Original file line numberDiff line numberDiff line change
@@ -843,15 +843,13 @@ namespace ts.server.protocol {
843843
/**
844844
* A request to get encoded semantic classifications for a span in the file
845845
*/
846-
/** @internal */
847846
export interface EncodedSemanticClassificationsRequest extends FileRequest {
848847
arguments: EncodedSemanticClassificationsRequestArgs;
849848
}
850849

851850
/**
852851
* Arguments for EncodedSemanticClassificationsRequest request.
853852
*/
854-
/** @internal */
855853
export interface EncodedSemanticClassificationsRequestArgs extends FileRequestArgs {
856854
/**
857855
* Start position of the span.
@@ -868,6 +866,18 @@ namespace ts.server.protocol {
868866
format?: "original" | "2020"
869867
}
870868

869+
/** The response for a EncodedSemanticClassificationsRequest */
870+
export interface EncodedSemanticClassificationsResponse extends Response {
871+
body?: EncodedSemanticClassificationsResponseBody
872+
}
873+
874+
/**
875+
* Implementation response message. Gives series of text spans depending on the format ar.
876+
*/
877+
export interface EncodedSemanticClassificationsResponseBody {
878+
endOfLineState: EndOfLineState;
879+
spans: number[];
880+
}
871881
/**
872882
* Arguments in document highlight request; include: filesToSearch, file,
873883
* line, offset.
@@ -3390,4 +3400,32 @@ namespace ts.server.protocol {
33903400
ES2020 = "ES2020",
33913401
ESNext = "ESNext"
33923402
}
3403+
3404+
export const enum ClassificationType {
3405+
comment = 1,
3406+
identifier = 2,
3407+
keyword = 3,
3408+
numericLiteral = 4,
3409+
operator = 5,
3410+
stringLiteral = 6,
3411+
regularExpressionLiteral = 7,
3412+
whiteSpace = 8,
3413+
text = 9,
3414+
punctuation = 10,
3415+
className = 11,
3416+
enumName = 12,
3417+
interfaceName = 13,
3418+
moduleName = 14,
3419+
typeParameterName = 15,
3420+
typeAliasName = 16,
3421+
parameterName = 17,
3422+
docCommentTagName = 18,
3423+
jsxOpenTagName = 19,
3424+
jsxCloseTagName = 20,
3425+
jsxSelfClosingTagName = 21,
3426+
jsxAttribute = 22,
3427+
jsxText = 23,
3428+
jsxAttributeStringLiteralValue = 24,
3429+
bigintLiteral = 25,
3430+
}
33933431
}

tests/baselines/reference/api/tsserverlibrary.d.ts

+62
Original file line numberDiff line numberDiff line change
@@ -7136,6 +7136,41 @@ declare namespace ts.server.protocol {
71367136
*/
71377137
body?: string[];
71387138
}
7139+
/**
7140+
* A request to get encoded semantic classifications for a span in the file
7141+
*/
7142+
interface EncodedSemanticClassificationsRequest extends FileRequest {
7143+
arguments: EncodedSemanticClassificationsRequestArgs;
7144+
}
7145+
/**
7146+
* Arguments for EncodedSemanticClassificationsRequest request.
7147+
*/
7148+
interface EncodedSemanticClassificationsRequestArgs extends FileRequestArgs {
7149+
/**
7150+
* Start position of the span.
7151+
*/
7152+
start: number;
7153+
/**
7154+
* Length of the span.
7155+
*/
7156+
length: number;
7157+
/**
7158+
* Optional parameter for the semantic highlighting response, if absent it
7159+
* defaults to "original".
7160+
*/
7161+
format?: "original" | "2020";
7162+
}
7163+
/** The response for a EncodedSemanticClassificationsRequest */
7164+
interface EncodedSemanticClassificationsResponse extends Response {
7165+
body?: EncodedSemanticClassificationsResponseBody;
7166+
}
7167+
/**
7168+
* Implementation response message. Gives series of text spans depending on the format ar.
7169+
*/
7170+
interface EncodedSemanticClassificationsResponseBody {
7171+
endOfLineState: EndOfLineState;
7172+
spans: number[];
7173+
}
71397174
/**
71407175
* Arguments in document highlight request; include: filesToSearch, file,
71417176
* line, offset.
@@ -9159,6 +9194,33 @@ declare namespace ts.server.protocol {
91599194
ES2020 = "ES2020",
91609195
ESNext = "ESNext"
91619196
}
9197+
enum ClassificationType {
9198+
comment = 1,
9199+
identifier = 2,
9200+
keyword = 3,
9201+
numericLiteral = 4,
9202+
operator = 5,
9203+
stringLiteral = 6,
9204+
regularExpressionLiteral = 7,
9205+
whiteSpace = 8,
9206+
text = 9,
9207+
punctuation = 10,
9208+
className = 11,
9209+
enumName = 12,
9210+
interfaceName = 13,
9211+
moduleName = 14,
9212+
typeParameterName = 15,
9213+
typeAliasName = 16,
9214+
parameterName = 17,
9215+
docCommentTagName = 18,
9216+
jsxOpenTagName = 19,
9217+
jsxCloseTagName = 20,
9218+
jsxSelfClosingTagName = 21,
9219+
jsxAttribute = 22,
9220+
jsxText = 23,
9221+
jsxAttributeStringLiteralValue = 24,
9222+
bigintLiteral = 25
9223+
}
91629224
}
91639225
declare namespace ts.server {
91649226
interface ScriptInfoVersion {

0 commit comments

Comments
 (0)