diff --git a/src/server/protocol.ts b/src/server/protocol.ts index 2650cd5d765..d4ad6e7f0f1 100644 --- a/src/server/protocol.ts +++ b/src/server/protocol.ts @@ -94,6 +94,8 @@ namespace ts.server.protocol { ApplyChangedToOpenFiles = "applyChangedToOpenFiles", UpdateOpen = "updateOpen", /* @internal */ + EncodedSyntacticClassificationsFull = "encodedSyntacticClassifications-full", + /* @internal */ EncodedSemanticClassificationsFull = "encodedSemanticClassifications-full", /* @internal */ Cleanup = "cleanup", @@ -764,6 +766,29 @@ namespace ts.server.protocol { body?: string[]; } + /** + * A request to get encoded Syntactic classifications for a span in the file + */ + /** @internal */ + export interface EncodedSyntacticClassificationsRequest extends FileRequest { + arguments: EncodedSyntacticClassificationsRequestArgs; + } + + /** + * Arguments for EncodedSyntacticClassificationsRequest request. + */ + /** @internal */ + export interface EncodedSyntacticClassificationsRequestArgs extends FileRequestArgs { + /** + * Start position of the span. + */ + start: number; + /** + * Length of the span. + */ + length: number; + } + /** * A request to get encoded semantic classifications for a span in the file */ @@ -775,6 +800,7 @@ namespace ts.server.protocol { /** * Arguments for EncodedSemanticClassificationsRequest request. */ + /** @internal */ export interface EncodedSemanticClassificationsRequestArgs extends FileRequestArgs { /** * Start position of the span. diff --git a/src/server/session.ts b/src/server/session.ts index 5064b529560..d663ca09249 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -881,6 +881,11 @@ namespace ts.server { } } + private getEncodedSyntacticClassifications(args: protocol.EncodedSyntacticClassificationsRequestArgs) { + const { file, languageService } = this.getFileAndLanguageServiceForSyntacticOperation(args); + return languageService.getEncodedSyntacticClassifications(file, args); + } + private getEncodedSemanticClassifications(args: protocol.EncodedSemanticClassificationsRequestArgs) { const { file, project } = this.getFileAndProject(args); return project.getLanguageService().getEncodedSemanticClassifications(file, args); @@ -2299,6 +2304,9 @@ namespace ts.server { [CommandNames.CompilerOptionsDiagnosticsFull]: (request: protocol.CompilerOptionsDiagnosticsRequest) => { return this.requiredResponse(this.getCompilerOptionsDiagnostics(request.arguments)); }, + [CommandNames.EncodedSyntacticClassificationsFull]: (request: protocol.EncodedSyntacticClassificationsRequest) => { + return this.requiredResponse(this.getEncodedSyntacticClassifications(request.arguments)); + }, [CommandNames.EncodedSemanticClassificationsFull]: (request: protocol.EncodedSemanticClassificationsRequest) => { return this.requiredResponse(this.getEncodedSemanticClassifications(request.arguments)); }, diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 82ab70b6e6f..505af006287 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -6415,19 +6415,6 @@ declare namespace ts.server.protocol { */ body?: string[]; } - /** - * Arguments for EncodedSemanticClassificationsRequest request. - */ - interface EncodedSemanticClassificationsRequestArgs extends FileRequestArgs { - /** - * Start position of the span. - */ - start: number; - /** - * Length of the span. - */ - length: number; - } /** * Arguments in document highlight request; include: filesToSearch, file, * line, offset. @@ -9076,6 +9063,7 @@ declare namespace ts.server { private updateErrorCheck; private cleanProjects; private cleanup; + private getEncodedSyntacticClassifications; private getEncodedSemanticClassifications; private getProject; private getConfigFileAndProject;