Skip to content

Commit

Permalink
Expose EncodedSemanticClassificationsRequest in protocol.d.ts (micros…
Browse files Browse the repository at this point in the history
…oft#42640) (microsoft#42965)

* Expose EncodedSemanticClassificationsRequest in protocol.d.ts

* Adds the response for encoded semantic highlights too

* Update types:

* Also include classificationtype anyway

* Fix feedback
  • Loading branch information
Orta Therox authored Feb 25, 2021
1 parent 08ad0e2 commit acc5fa0
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 2 deletions.
42 changes: 40 additions & 2 deletions src/server/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -843,15 +843,13 @@ namespace ts.server.protocol {
/**
* A request to get encoded semantic classifications for a span in the file
*/
/** @internal */
export interface EncodedSemanticClassificationsRequest extends FileRequest {
arguments: EncodedSemanticClassificationsRequestArgs;
}

/**
* Arguments for EncodedSemanticClassificationsRequest request.
*/
/** @internal */
export interface EncodedSemanticClassificationsRequestArgs extends FileRequestArgs {
/**
* Start position of the span.
Expand All @@ -868,6 +866,18 @@ namespace ts.server.protocol {
format?: "original" | "2020"
}

/** The response for a EncodedSemanticClassificationsRequest */
export interface EncodedSemanticClassificationsResponse extends Response {
body?: EncodedSemanticClassificationsResponseBody
}

/**
* Implementation response message. Gives series of text spans depending on the format ar.
*/
export interface EncodedSemanticClassificationsResponseBody {
endOfLineState: EndOfLineState;
spans: number[];
}
/**
* Arguments in document highlight request; include: filesToSearch, file,
* line, offset.
Expand Down Expand Up @@ -3390,4 +3400,32 @@ namespace ts.server.protocol {
ES2020 = "ES2020",
ESNext = "ESNext"
}

export const 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,
}
}
62 changes: 62 additions & 0 deletions tests/baselines/reference/api/tsserverlibrary.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7136,6 +7136,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 {
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: number[];
}
/**
* Arguments in document highlight request; include: filesToSearch, file,
* line, offset.
Expand Down Expand Up @@ -9159,6 +9194,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 {
Expand Down

0 comments on commit acc5fa0

Please sign in to comment.