summaryrefslogtreecommitdiff
path: root/cli/tsc
diff options
context:
space:
mode:
authorJean Pierre <jeanp413@hotmail.com>2021-08-05 20:46:32 -0500
committerGitHub <noreply@github.com>2021-08-06 11:46:32 +1000
commit728d205d9d2551a356a022b6b083bcdcf081f3bf (patch)
treec0823fef3a96ed164379c5297d521fce9b2628d8 /cli/tsc
parent3f0cf9619fce71a8898c495501df4bdb0e07e735 (diff)
feat(lsp): implement refactoring code actions (#11555)
Closes: denoland/vscode_deno#433
Diffstat (limited to 'cli/tsc')
-rw-r--r--cli/tsc/99_main_compiler.js38
-rw-r--r--cli/tsc/compiler.d.ts17
2 files changed, 55 insertions, 0 deletions
diff --git a/cli/tsc/99_main_compiler.js b/cli/tsc/99_main_compiler.js
index f5cfe38dd..29a387887 100644
--- a/cli/tsc/99_main_compiler.js
+++ b/cli/tsc/99_main_compiler.js
@@ -584,6 +584,44 @@ delete Object.prototype.__proto__;
);
return respond(id, sourceFile && sourceFile.text);
}
+ case "getApplicableRefactors": {
+ return respond(
+ id,
+ languageService.getApplicableRefactors(
+ request.specifier,
+ request.range,
+ {
+ quotePreference: "double",
+ allowTextChangesInNewFiles: true,
+ provideRefactorNotApplicableReason: true,
+ },
+ undefined,
+ request.kind,
+ ),
+ );
+ }
+ case "getEditsForRefactor": {
+ return respond(
+ id,
+ languageService.getEditsForRefactor(
+ request.specifier,
+ {
+ indentSize: 2,
+ indentStyle: ts.IndentStyle.Smart,
+ semicolons: ts.SemicolonPreference.Insert,
+ convertTabsToSpaces: true,
+ insertSpaceBeforeAndAfterBinaryOperators: true,
+ insertSpaceAfterCommaDelimiter: true,
+ },
+ request.range,
+ request.refactorName,
+ request.actionName,
+ {
+ quotePreference: "double",
+ },
+ ),
+ );
+ }
case "getCodeFixes": {
return respond(
id,
diff --git a/cli/tsc/compiler.d.ts b/cli/tsc/compiler.d.ts
index 949d98ee0..ff2e59e8e 100644
--- a/cli/tsc/compiler.d.ts
+++ b/cli/tsc/compiler.d.ts
@@ -47,6 +47,8 @@ declare global {
| ConfigureRequest
| FindRenameLocationsRequest
| GetAsset
+ | GetApplicableRefactors
+ | GetEditsForRefactor
| GetCodeFixes
| GetCombinedCodeFix
| GetCompletionDetails
@@ -92,6 +94,21 @@ declare global {
specifier: string;
}
+ interface GetApplicableRefactors extends BaseLanguageServerRequest {
+ method: "getApplicableRefactors";
+ specifier: string;
+ range: ts.TextRange;
+ kind: string;
+ }
+
+ interface GetEditsForRefactor extends BaseLanguageServerRequest {
+ method: "getEditsForRefactor";
+ specifier: string;
+ range: ts.TextRange;
+ refactorName: string;
+ actionName: string;
+ }
+
interface GetCodeFixes extends BaseLanguageServerRequest {
method: "getCodeFixes";
specifier: string;