summaryrefslogtreecommitdiff
path: root/cli/tests
diff options
context:
space:
mode:
authorKitson Kelly <me@kitsonkelly.com>2021-02-05 05:53:02 +1100
committerGitHub <noreply@github.com>2021-02-05 05:53:02 +1100
commitb77fcbc518428429e39f5ba94e41fcd0418ee7a0 (patch)
tree0051cc7e5ac0c8f83278de093a2be7209cf9fcfc /cli/tests
parent644a7ff2d70cbd8bfba4c87b75a047e79830c4b6 (diff)
feat(lsp): add TS quick fix code actions (#9396)
Diffstat (limited to 'cli/tests')
-rw-r--r--cli/tests/lsp/code_action_request.json44
-rw-r--r--cli/tests/lsp/code_action_response.json150
-rw-r--r--cli/tests/lsp/did_open_notification_code_action.json12
-rw-r--r--cli/tests/lsp/initialize_request.json16
4 files changed, 222 insertions, 0 deletions
diff --git a/cli/tests/lsp/code_action_request.json b/cli/tests/lsp/code_action_request.json
new file mode 100644
index 000000000..af6cbee8b
--- /dev/null
+++ b/cli/tests/lsp/code_action_request.json
@@ -0,0 +1,44 @@
+{
+ "jsonrpc": "2.0",
+ "id": 2,
+ "method": "textDocument/codeAction",
+ "params": {
+ "textDocument": {
+ "uri": "file:///a/file.ts"
+ },
+ "range": {
+ "start": {
+ "line": 1,
+ "character": 2
+ },
+ "end": {
+ "line": 1,
+ "character": 7
+ }
+ },
+ "context": {
+ "diagnostics": [
+ {
+ "range": {
+ "start": {
+ "line": 1,
+ "character": 2
+ },
+ "end": {
+ "line": 1,
+ "character": 7
+ }
+ },
+ "severity": 1,
+ "code": 1308,
+ "source": "deno-ts",
+ "message": "'await' expressions are only allowed within async functions and at the top levels of modules.",
+ "relatedInformation": []
+ }
+ ],
+ "only": [
+ "quickfix"
+ ]
+ }
+ }
+}
diff --git a/cli/tests/lsp/code_action_response.json b/cli/tests/lsp/code_action_response.json
new file mode 100644
index 000000000..5af45ba7f
--- /dev/null
+++ b/cli/tests/lsp/code_action_response.json
@@ -0,0 +1,150 @@
+[
+ {
+ "title": "Add async modifier to containing function",
+ "kind": "quickfix",
+ "diagnostics": [
+ {
+ "range": {
+ "start": {
+ "line": 1,
+ "character": 2
+ },
+ "end": {
+ "line": 1,
+ "character": 7
+ }
+ },
+ "severity": 1,
+ "code": 1308,
+ "source": "deno-ts",
+ "message": "'await' expressions are only allowed within async functions and at the top levels of modules.",
+ "relatedInformation": []
+ }
+ ],
+ "edit": {
+ "documentChanges": [
+ {
+ "textDocument": {
+ "uri": "file:///a/file.ts",
+ "version": 1
+ },
+ "edits": [
+ {
+ "range": {
+ "start": {
+ "line": 0,
+ "character": 7
+ },
+ "end": {
+ "line": 0,
+ "character": 7
+ }
+ },
+ "newText": "async "
+ },
+ {
+ "range": {
+ "start": {
+ "line": 0,
+ "character": 21
+ },
+ "end": {
+ "line": 0,
+ "character": 25
+ }
+ },
+ "newText": "Promise<void>"
+ }
+ ]
+ }
+ ]
+ }
+ },
+ {
+ "title": "Add all missing 'async' modifiers",
+ "kind": "quickfix",
+ "diagnostics": [
+ {
+ "range": {
+ "start": {
+ "line": 1,
+ "character": 2
+ },
+ "end": {
+ "line": 1,
+ "character": 7
+ }
+ },
+ "severity": 1,
+ "code": 1308,
+ "source": "deno-ts",
+ "message": "'await' expressions are only allowed within async functions and at the top levels of modules.",
+ "relatedInformation": []
+ }
+ ],
+ "edit": {
+ "documentChanges": [
+ {
+ "textDocument": {
+ "uri": "file:///a/file.ts",
+ "version": 1
+ },
+ "edits": [
+ {
+ "range": {
+ "start": {
+ "line": 0,
+ "character": 7
+ },
+ "end": {
+ "line": 0,
+ "character": 7
+ }
+ },
+ "newText": "async "
+ },
+ {
+ "range": {
+ "start": {
+ "line": 0,
+ "character": 21
+ },
+ "end": {
+ "line": 0,
+ "character": 25
+ }
+ },
+ "newText": "Promise<void>"
+ },
+ {
+ "range": {
+ "start": {
+ "line": 4,
+ "character": 7
+ },
+ "end": {
+ "line": 4,
+ "character": 7
+ }
+ },
+ "newText": "async "
+ },
+ {
+ "range": {
+ "start": {
+ "line": 4,
+ "character": 21
+ },
+ "end": {
+ "line": 4,
+ "character": 25
+ }
+ },
+ "newText": "Promise<void>"
+ }
+ ]
+ }
+ ]
+ }
+ }
+]
diff --git a/cli/tests/lsp/did_open_notification_code_action.json b/cli/tests/lsp/did_open_notification_code_action.json
new file mode 100644
index 000000000..57559cf3c
--- /dev/null
+++ b/cli/tests/lsp/did_open_notification_code_action.json
@@ -0,0 +1,12 @@
+{
+ "jsonrpc": "2.0",
+ "method": "textDocument/didOpen",
+ "params": {
+ "textDocument": {
+ "uri": "file:///a/file.ts",
+ "languageId": "typescript",
+ "version": 1,
+ "text": "export function a(): void {\n await Promise.resolve(\"a\");\n}\n\nexport function b(): void {\n await Promise.resolve(\"b\");\n}\n"
+ }
+ }
+}
diff --git a/cli/tests/lsp/initialize_request.json b/cli/tests/lsp/initialize_request.json
index 46f96a2c5..eaea00a18 100644
--- a/cli/tests/lsp/initialize_request.json
+++ b/cli/tests/lsp/initialize_request.json
@@ -20,6 +20,22 @@
},
"capabilities": {
"textDocument": {
+ "codeAction": {
+ "codeActionLiteralSupport": {
+ "codeActionKind": {
+ "valueSet": [
+ "quickfix"
+ ]
+ }
+ },
+ "isPreferredSupport": true,
+ "dataSupport": true,
+ "resolveSupport": {
+ "properties": [
+ "edit"
+ ]
+ }
+ },
"synchronization": {
"dynamicRegistration": true,
"willSave": true,