From 6e5085314399fefbb29a9fd504779950e18fd634 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Tue, 18 Jun 2019 16:44:48 -0700 Subject: [PATCH 1/4] 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)); }, From 2953574ebaaf61bc785f36d191fe4441491e76b5 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Fri, 21 Jun 2019 14:48:22 -0700 Subject: [PATCH 2/4] Use getEncodedSyntacticClassifications --- src/server/session.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/server/session.ts b/src/server/session.ts index 8e5ca896c2b..d663ca09249 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -882,8 +882,8 @@ namespace ts.server { } private getEncodedSyntacticClassifications(args: protocol.EncodedSyntacticClassificationsRequestArgs) { - const { file, project } = this.getFileAndProject(args); - return project.getLanguageService().getEncodedSyntacticClassifications(file, args); + const { file, languageService } = this.getFileAndLanguageServiceForSyntacticOperation(args); + return languageService.getEncodedSyntacticClassifications(file, args); } private getEncodedSemanticClassifications(args: protocol.EncodedSemanticClassificationsRequestArgs) { From 96fcf1e0c0778e4cd40756dc779949c53f3710df Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Fri, 21 Jun 2019 14:55:29 -0700 Subject: [PATCH 3/4] Update API baseline --- tests/baselines/reference/api/tsserverlibrary.d.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index cbab57b0644..69c60446f5e 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -6414,6 +6414,19 @@ declare namespace ts.server.protocol { */ body?: string[]; } + /** + * Arguments for EncodedSyntacticClassificationsRequest request. + */ + interface EncodedSyntacticClassificationsRequestArgs extends FileRequestArgs { + /** + * Start position of the span. + */ + start: number; + /** + * Length of the span. + */ + length: number; + } /** * Arguments for EncodedSemanticClassificationsRequest request. */ @@ -9075,6 +9088,7 @@ declare namespace ts.server { private updateErrorCheck; private cleanProjects; private cleanup; + private getEncodedSyntacticClassifications; private getEncodedSemanticClassifications; private getProject; private getConfigFileAndProject; From 2d785c8c91fb1f770907fa3b14337349b82753df Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Wed, 26 Jun 2019 15:09:30 -0700 Subject: [PATCH 4/4] Make args types internal --- src/server/protocol.ts | 2 ++ .../reference/api/tsserverlibrary.d.ts | 26 ------------------- 2 files changed, 2 insertions(+), 26 deletions(-) diff --git a/src/server/protocol.ts b/src/server/protocol.ts index a23efb4ef29..d4ad6e7f0f1 100644 --- a/src/server/protocol.ts +++ b/src/server/protocol.ts @@ -777,6 +777,7 @@ namespace ts.server.protocol { /** * Arguments for EncodedSyntacticClassificationsRequest request. */ + /** @internal */ export interface EncodedSyntacticClassificationsRequestArgs extends FileRequestArgs { /** * Start position of the span. @@ -799,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/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 69c60446f5e..618f1c1263d 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -6414,32 +6414,6 @@ declare namespace ts.server.protocol { */ body?: string[]; } - /** - * Arguments for EncodedSyntacticClassificationsRequest request. - */ - interface EncodedSyntacticClassificationsRequestArgs extends FileRequestArgs { - /** - * Start position of the span. - */ - start: number; - /** - * Length of the span. - */ - length: number; - } - /** - * 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.