diff options
Diffstat (limited to 'cli/tsc')
-rw-r--r-- | cli/tsc/99_main_compiler.js | 45 | ||||
-rw-r--r-- | cli/tsc/compiler.d.ts | 24 |
2 files changed, 68 insertions, 1 deletions
diff --git a/cli/tsc/99_main_compiler.js b/cli/tsc/99_main_compiler.js index fa25b207f..50631e83f 100644 --- a/cli/tsc/99_main_compiler.js +++ b/cli/tsc/99_main_compiler.js @@ -555,6 +555,45 @@ delete Object.prototype.__proto__; ); return respond(id, sourceFile && sourceFile.text); } + case "getCodeFixes": { + return respond( + id, + languageService.getCodeFixesAtPosition( + request.specifier, + request.startPosition, + request.endPosition, + request.errorCodes.map((v) => Number(v)), + { + indentSize: 2, + indentStyle: ts.IndentStyle.Block, + semicolons: ts.SemicolonPreference.Insert, + }, + { + quotePreference: "double", + }, + ), + ); + } + case "getCombinedCodeFix": { + return respond( + id, + languageService.getCombinedCodeFix( + { + type: "file", + fileName: request.specifier, + }, + request.fixId, + { + indentSize: 2, + indentStyle: ts.IndentStyle.Block, + semicolons: ts.SemicolonPreference.Insert, + }, + { + quotePreference: "double", + }, + ), + ); + } case "getCompletions": { return respond( id, @@ -638,6 +677,12 @@ delete Object.prototype.__proto__; ), ); } + case "getSupportedCodeFixes": { + return respond( + id, + ts.getSupportedCodeFixes(), + ); + } default: throw new TypeError( // @ts-ignore exhausted case statement sets type to never diff --git a/cli/tsc/compiler.d.ts b/cli/tsc/compiler.d.ts index 17d6ddb38..4e5dcdb96 100644 --- a/cli/tsc/compiler.d.ts +++ b/cli/tsc/compiler.d.ts @@ -44,6 +44,8 @@ declare global { | ConfigureRequest | FindRenameLocationsRequest | GetAsset + | GetCodeFixes + | GetCombinedCodeFix | GetCompletionsRequest | GetDefinitionRequest | GetDiagnosticsRequest @@ -51,7 +53,8 @@ declare global { | GetImplementationRequest | GetNavigationTree | GetQuickInfoRequest - | GetReferencesRequest; + | GetReferencesRequest + | GetSupportedCodeFixes; interface BaseLanguageServerRequest { id: number; @@ -78,6 +81,21 @@ declare global { specifier: string; } + interface GetCodeFixes extends BaseLanguageServerRequest { + method: "getCodeFixes"; + specifier: string; + startPosition: number; + endPosition: number; + errorCodes: string[]; + } + + interface GetCombinedCodeFix extends BaseLanguageServerRequest { + method: "getCombinedCodeFix"; + specifier: string; + // deno-lint-ignore ban-types + fixId: {}; + } + interface GetCompletionsRequest extends BaseLanguageServerRequest { method: "getCompletions"; specifier: string; @@ -125,4 +143,8 @@ declare global { specifier: string; position: number; } + + interface GetSupportedCodeFixes extends BaseLanguageServerRequest { + method: "getSupportedCodeFixes"; + } } |