Skip to content

Commit a2f09ed

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

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

0 commit comments

Comments
 (0)