From f7e416bc7fbb8b1bc17e180d5aeb2e4f00256bea Mon Sep 17 00:00:00 2001 From: Kitson Kelly Date: Tue, 10 Aug 2021 09:56:34 +1000 Subject: feat(lsp): support clients which do not support disabled code actions (#11612) Closes: #11610 --- cli/tests/lsp/code_action_response_refactor.json | 130 +++++++++++++---------- 1 file changed, 75 insertions(+), 55 deletions(-) (limited to 'cli/tests/lsp/code_action_response_refactor.json') diff --git a/cli/tests/lsp/code_action_response_refactor.json b/cli/tests/lsp/code_action_response_refactor.json index 87f354e37..a9fbd2827 100644 --- a/cli/tests/lsp/code_action_response_refactor.json +++ b/cli/tests/lsp/code_action_response_refactor.json @@ -1,139 +1,136 @@ [ { - "title": "Extract to type alias", - "kind": "refactor.extract.type", - "isPreferred": true, + "title": "Extract to function in global scope", + "kind": "refactor.extract.function", + "isPreferred": false, "data": { "specifier": "file:///a/file.ts", "range": { "start": { "line": 0, - "character": 7 + "character": 0 }, "end": { - "line": 0, - "character": 33 + "line": 1, + "character": 0 } }, - "refactorName": "Extract type", - "actionName": "Extract to type alias" + "refactorName": "Extract Symbol", + "actionName": "function_scope_0" } }, { - "title": "Extract to interface", - "kind": "refactor.extract.interface", - "isPreferred": true, + "title": "Extract to constant in enclosing scope", + "kind": "refactor.extract.constant", + "isPreferred": false, "data": { "specifier": "file:///a/file.ts", "range": { "start": { "line": 0, - "character": 7 + "character": 0 }, "end": { - "line": 0, - "character": 33 + "line": 1, + "character": 0 } }, - "refactorName": "Extract type", - "actionName": "Extract to interface" + "refactorName": "Extract Symbol", + "actionName": "constant_scope_0" } }, { - "title": "Extract function", - "kind": "refactor.extract.function", + "title": "Move to a new file", + "kind": "refactor.move.newFile", "isPreferred": false, - "disabled": { - "reason": "Statement or expression expected." - }, "data": { "specifier": "file:///a/file.ts", "range": { "start": { "line": 0, - "character": 7 + "character": 0 }, "end": { - "line": 0, - "character": 33 + "line": 1, + "character": 0 } }, - "refactorName": "Extract Symbol", - "actionName": "Extract Function" + "refactorName": "Move to a new file", + "actionName": "Move to a new file" } }, { - "title": "Extract constant", - "kind": "refactor.extract.constant", + "title": "Convert default export to named export", + "kind": "refactor.rewrite.export.named", "isPreferred": false, "disabled": { - "reason": "Statement or expression expected." + "reason": "This file already has a default export" }, "data": { "specifier": "file:///a/file.ts", "range": { "start": { "line": 0, - "character": 7 + "character": 0 }, "end": { - "line": 0, - "character": 33 + "line": 1, + "character": 0 } }, - "refactorName": "Extract Symbol", - "actionName": "Extract Constant" + "refactorName": "Convert export", + "actionName": "Convert default export to named export" } }, { - "title": "Convert default export to named export", - "kind": "refactor.rewrite.export.named", + "title": "Convert named export to default export", + "kind": "refactor.rewrite.export.default", "isPreferred": false, "disabled": { - "reason": "Could not find export statement" + "reason": "This file already has a default export" }, "data": { "specifier": "file:///a/file.ts", "range": { "start": { "line": 0, - "character": 7 + "character": 0 }, "end": { - "line": 0, - "character": 33 + "line": 1, + "character": 0 } }, "refactorName": "Convert export", - "actionName": "Convert default export to named export" + "actionName": "Convert named export to default export" } }, { - "title": "Convert named export to default export", - "kind": "refactor.rewrite.export.default", + "title": "Convert namespace import to named imports", + "kind": "refactor.rewrite.import.named", "isPreferred": false, "disabled": { - "reason": "Could not find export statement" + "reason": "Selection is not an import declaration." }, "data": { "specifier": "file:///a/file.ts", "range": { "start": { "line": 0, - "character": 7 + "character": 0 }, "end": { - "line": 0, - "character": 33 + "line": 1, + "character": 0 } }, - "refactorName": "Convert export", - "actionName": "Convert named export to default export" + "refactorName": "Convert import", + "actionName": "Convert namespace import to named imports" } }, { - "title": "Convert namespace import to named imports", - "kind": "refactor.rewrite.import.named", + "title": "Convert named imports to namespace import", + "kind": "refactor.rewrite.import.namespace", "isPreferred": false, "disabled": { "reason": "Selection is not an import declaration." @@ -143,15 +140,38 @@ "range": { "start": { "line": 0, - "character": 7 + "character": 0 }, "end": { - "line": 0, - "character": 33 + "line": 1, + "character": 0 } }, "refactorName": "Convert import", - "actionName": "Convert namespace import to named imports" + "actionName": "Convert named imports to namespace import" + } + }, + { + "title": "Convert to optional chain expression", + "kind": "refactor.rewrite.expression.optionalChain", + "isPreferred": false, + "disabled": { + "reason": "Could not find convertible access expression" + }, + "data": { + "specifier": "file:///a/file.ts", + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 1, + "character": 0 + } + }, + "refactorName": "Convert to optional chain expression", + "actionName": "Convert to optional chain expression" } } ] -- cgit v1.2.3