Skip to content

Commit

Permalink
Adds Format param to the tsserver session (#41614)
Browse files Browse the repository at this point in the history
* Adds the format flag for encodedSemanticClassifications in session.ts and protocol.ts

* Update baselines

* Whitespace"
  • Loading branch information
Orta Therox committed Nov 20, 2020
1 parent f1e53da commit 9d25e59
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
9 changes: 8 additions & 1 deletion src/server/protocol.ts
Expand Up @@ -838,7 +838,6 @@ namespace ts.server.protocol {
export interface EncodedSemanticClassificationsRequest extends FileRequest {
arguments: EncodedSemanticClassificationsRequestArgs;
}

/**
* Arguments for EncodedSemanticClassificationsRequest request.
*/
Expand All @@ -852,6 +851,10 @@ namespace ts.server.protocol {
* Length of the span.
*/
length: number;
/**
* Optional for backwards compat, use "2020" for modern LSP-like classifications
*/
format?: ts.SemanticClassificationFormat
}

/**
Expand Down Expand Up @@ -3318,6 +3321,8 @@ namespace ts.server.protocol {
Preserve = "Preserve",
ReactNative = "ReactNative",
React = "React",
ReactJSX = "ReactJSX",
ReactJSXDev = "ReactJSXDev",
}

export const enum ModuleKind {
Expand All @@ -3328,6 +3333,7 @@ namespace ts.server.protocol {
System = "System",
ES6 = "ES6",
ES2015 = "ES2015",
ES2020 = "ES2020",
ESNext = "ESNext"
}

Expand All @@ -3351,6 +3357,7 @@ namespace ts.server.protocol {
ES2018 = "ES2018",
ES2019 = "ES2019",
ES2020 = "ES2020",
JSON = "JSON",
ESNext = "ESNext"
}
}
2 changes: 1 addition & 1 deletion src/server/session.ts
Expand Up @@ -1081,7 +1081,7 @@ namespace ts.server {

private getEncodedSemanticClassifications(args: protocol.EncodedSemanticClassificationsRequestArgs) {
const { file, project } = this.getFileAndProject(args);
return project.getLanguageService().getEncodedSemanticClassifications(file, args);
return project.getLanguageService().getEncodedSemanticClassifications(file, args, args.format);
}

private getProject(projectFileName: string | undefined): Project | undefined {
Expand Down
6 changes: 5 additions & 1 deletion tests/baselines/reference/api/tsserverlibrary.d.ts
Expand Up @@ -9084,7 +9084,9 @@ declare namespace ts.server.protocol {
None = "None",
Preserve = "Preserve",
ReactNative = "ReactNative",
React = "React"
React = "React",
ReactJSX = "ReactJSX",
ReactJSXDev = "ReactJSXDev"
}
enum ModuleKind {
None = "None",
Expand All @@ -9094,6 +9096,7 @@ declare namespace ts.server.protocol {
System = "System",
ES6 = "ES6",
ES2015 = "ES2015",
ES2020 = "ES2020",
ESNext = "ESNext"
}
enum ModuleResolutionKind {
Expand All @@ -9114,6 +9117,7 @@ declare namespace ts.server.protocol {
ES2018 = "ES2018",
ES2019 = "ES2019",
ES2020 = "ES2020",
JSON = "JSON",
ESNext = "ESNext"
}
}
Expand Down

0 comments on commit 9d25e59

Please sign in to comment.