Skip to content

Commit 1ebad64

Browse files
committed
WIP-semantic in session based TS
1 parent a894f8a commit 1ebad64

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

src/server/protocol.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,11 @@ namespace ts.server.protocol {
861861
* Length of the span.
862862
*/
863863
length: number;
864+
/**
865+
* Optional parameter for the semantic highlighting response, if absent it
866+
* defaults to "original".
867+
*/
868+
format?: "original" | "2020"
864869
}
865870

866871
/**

src/server/session.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1115,7 +1115,8 @@ namespace ts.server {
11151115

11161116
private getEncodedSemanticClassifications(args: protocol.EncodedSemanticClassificationsRequestArgs) {
11171117
const { file, project } = this.getFileAndProject(args);
1118-
return project.getLanguageService().getEncodedSemanticClassifications(file, args);
1118+
const format = args.format === "2020" ? SemanticClassificationFormat.TwentyTwenty : SemanticClassificationFormat.Original;
1119+
return project.getLanguageService().getEncodedSemanticClassifications(file, args, format);
11191120
}
11201121

11211122
private getProject(projectFileName: string | undefined): Project | undefined {

src/services/shims.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -693,10 +693,10 @@ namespace ts {
693693
return realizeDiagnostics(diagnostics, newLine);
694694
}
695695

696-
public getSyntacticClassifications(fileName: string, start: number, length: number): string {
696+
public getSyntacticClassifications(fileName: string, start: number, length: number, format?: SemanticClassificationFormat): string {
697697
return this.forwardJSONCall(
698698
`getSyntacticClassifications('${fileName}', ${start}, ${length})`,
699-
() => this.languageService.getSyntacticClassifications(fileName, createTextSpan(start, length))
699+
() => this.languageService.getSyntacticClassifications(fileName, createTextSpan(start, length), format ||= SemanticClassificationFormat.Original)
700700
);
701701
}
702702

0 commit comments

Comments
 (0)