From 6e5085314399fefbb29a9fd504779950e18fd634 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Tue, 18 Jun 2019 16:44:48 -0700 Subject: [PATCH] Trivially expose getEncodedSyntacticClassifications --- src/server/protocol.ts | 24 ++++++++++++++++++++++++ src/server/session.ts | 8 ++++++++ 2 files changed, 32 insertions(+) diff --git a/src/server/protocol.ts b/src/server/protocol.ts index 2650cd5d765..a23efb4ef29 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,28 @@ 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. + */ + 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 */ diff --git a/src/server/session.ts b/src/server/session.ts index 5064b529560..8e5ca896c2b 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, project } = this.getFileAndProject(args); + return project.getLanguageService().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)); },