Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose EncodedSemanticClassificationsRequest in protocol.d.ts #42640

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/server/protocol.ts
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,14 @@ namespace ts.server.protocol {
format?: "original" | "2020"
}

/** The response for a EncodedSemanticClassificationsRequest */
export interface EncodedSemanticClassificationsResponse extends Response {
body?: {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull this out as EncodedSemanticClassificationsResponseBody interface

endOfLineState: EndOfLineState;
spans: number[];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dont we need specific enum for classifications returned otherwise vscode would need separate list?

Copy link
Contributor Author

@orta orta Feb 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, maybe, the spans looks like

     * @returns a number array encoded as triples of [start, length, ClassificationType, ...].

When it's the older format, so I've included it but it's not referenced up here

};
}

/**
* Arguments in document highlight request; include: filesToSearch, file,
* line, offset.
Expand Down
31 changes: 31 additions & 0 deletions tests/baselines/reference/api/tsserverlibrary.d.ts
Expand Up @@ -7133,6 +7133,37 @@ declare namespace ts.server.protocol {
*/
body?: string[];
}
/**
* A request to get encoded semantic classifications for a span in the file
*/
interface EncodedSemanticClassificationsRequest extends FileRequest {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren鈥檛 they in typescript/tsserver .d.ts ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We currently only use protocol.d.ts with VS Code. I think this should have all the types used communicating from or to tsserver

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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?: {
endOfLineState: EndOfLineState;
spans: number[];
};
}
/**
* Arguments in document highlight request; include: filesToSearch, file,
* line, offset.
Expand Down