Skip to content

Commit 2d44b8a

Browse files
committed
LanguageService: add getSupportedCodeFixes to make it proxyable
Fixes: microsoft#28966
1 parent 3c408d8 commit 2d44b8a

File tree

8 files changed

+18
-1
lines changed

8 files changed

+18
-1
lines changed

src/harness/client.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,5 +741,9 @@ namespace ts.server {
741741
dispose(): void {
742742
throw new Error("dispose is not available through the server layer.");
743743
}
744+
745+
getSupportedCodeFixes() {
746+
return getSupportedCodeFixes();
747+
}
744748
}
745749
}

src/harness/harnessLanguageService.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,9 @@ namespace Harness.LanguageService {
578578
return ts.notImplemented();
579579
}
580580
dispose(): void { this.shim.dispose({}); }
581+
getSupportedCodeFixes(): ReadonlyArray<string> {
582+
throw new Error("Not supported on the shim.");
583+
}
581584
}
582585

583586
export class ShimLanguageServiceAdapter implements LanguageServiceAdapter {

src/server/protocol.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,7 @@ namespace ts.server.protocol {
748748
*/
749749
export interface GetSupportedCodeFixesRequest extends Request {
750750
command: CommandTypes.GetSupportedCodeFixes;
751+
arguments?: Partial<FileRequestArgs>;
751752
}
752753

753754
/**

src/server/session.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1803,7 +1803,11 @@ namespace ts.server {
18031803
}
18041804
}
18051805

1806-
private getSupportedCodeFixes(): string[] {
1806+
private getSupportedCodeFixes(args?: protocol.FileRequestArgs): ReadonlyArray<string> {
1807+
if (args && args.file) {
1808+
const {project} = this.getFileAndProject(args);
1809+
return project.getLanguageService(/*ensureSynchronized*/ false).getSupportedCodeFixes();
1810+
}
18071811
return getSupportedCodeFixes();
18081812
}
18091813

src/services/services.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2143,6 +2143,7 @@ namespace ts {
21432143
getEditsForRefactor,
21442144
toLineColumnOffset: sourceMapper.toLineColumnOffset,
21452145
getSourceMapper: () => sourceMapper,
2146+
getSupportedCodeFixes,
21462147
};
21472148
}
21482149

src/services/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ namespace ts {
356356
/* @internal */ getNonBoundSourceFile(fileName: string): SourceFile;
357357

358358
dispose(): void;
359+
getSupportedCodeFixes(): ReadonlyArray<string>;
359360
}
360361

361362
export interface JsxClosingTagInfo {

tests/baselines/reference/api/tsserverlibrary.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4754,6 +4754,7 @@ declare namespace ts {
47544754
getEmitOutput(fileName: string, emitOnlyDtsFiles?: boolean): EmitOutput;
47554755
getProgram(): Program | undefined;
47564756
dispose(): void;
4757+
getSupportedCodeFixes(): ReadonlyArray<string>;
47574758
}
47584759
interface JsxClosingTagInfo {
47594760
readonly newText: string;
@@ -6199,6 +6200,7 @@ declare namespace ts.server.protocol {
61996200
*/
62006201
interface GetSupportedCodeFixesRequest extends Request {
62016202
command: CommandTypes.GetSupportedCodeFixes;
6203+
arguments?: Partial<FileRequestArgs>;
62026204
}
62036205
/**
62046206
* A response for GetSupportedCodeFixesRequest request.

tests/baselines/reference/api/typescript.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4754,6 +4754,7 @@ declare namespace ts {
47544754
getEmitOutput(fileName: string, emitOnlyDtsFiles?: boolean): EmitOutput;
47554755
getProgram(): Program | undefined;
47564756
dispose(): void;
4757+
getSupportedCodeFixes(): ReadonlyArray<string>;
47574758
}
47584759
interface JsxClosingTagInfo {
47594760
readonly newText: string;

0 commit comments

Comments
 (0)