summaryrefslogtreecommitdiff
path: root/cli/tests/testdata/lsp
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2021-08-11 10:20:47 -0400
committerGitHub <noreply@github.com>2021-08-11 10:20:47 -0400
commit15a763152f9d392cb80692262f8de5ef8ae15495 (patch)
treefcd1a59777f95920bf3502519983d6cc0d882a9a /cli/tests/testdata/lsp
parenta0285e2eb88f6254f6494b0ecd1878db3a3b2a58 (diff)
chore: move test files to testdata directory (#11601)
Diffstat (limited to 'cli/tests/testdata/lsp')
-rw-r--r--cli/tests/testdata/lsp/a.d.ts1
-rw-r--r--cli/tests/testdata/lsp/b.d.ts1
-rw-r--r--cli/tests/testdata/lsp/code_action_ignore_lint_params.json39
-rw-r--r--cli/tests/testdata/lsp/code_action_ignore_lint_response.json62
-rw-r--r--cli/tests/testdata/lsp/code_action_params.json39
-rw-r--r--cli/tests/testdata/lsp/code_action_params_cache.json41
-rw-r--r--cli/tests/testdata/lsp/code_action_params_deadlock.json38
-rw-r--r--cli/tests/testdata/lsp/code_action_params_imports.json54
-rw-r--r--cli/tests/testdata/lsp/code_action_params_refactor.json21
-rw-r--r--cli/tests/testdata/lsp/code_action_resolve_params.json27
-rw-r--r--cli/tests/testdata/lsp/code_action_resolve_params_imports.json26
-rw-r--r--cli/tests/testdata/lsp/code_action_resolve_params_refactor.json20
-rw-r--r--cli/tests/testdata/lsp/code_action_resolve_response.json91
-rw-r--r--cli/tests/testdata/lsp/code_action_resolve_response_imports.json51
-rw-r--r--cli/tests/testdata/lsp/code_action_resolve_response_refactor.json58
-rw-r--r--cli/tests/testdata/lsp/code_action_response.json90
-rw-r--r--cli/tests/testdata/lsp/code_action_response_cache.json36
-rw-r--r--cli/tests/testdata/lsp/code_action_response_imports.json242
-rw-r--r--cli/tests/testdata/lsp/code_action_response_no_disabled.json22
-rw-r--r--cli/tests/testdata/lsp/code_action_response_refactor.json177
-rw-r--r--cli/tests/testdata/lsp/code_lens_resolve_response.json38
-rw-r--r--cli/tests/testdata/lsp/code_lens_resolve_response_impl.json38
-rw-r--r--cli/tests/testdata/lsp/code_lens_response.json34
-rw-r--r--cli/tests/testdata/lsp/code_lens_response_changed.json50
-rw-r--r--cli/tests/testdata/lsp/code_lens_response_impl.json98
-rw-r--r--cli/tests/testdata/lsp/code_lens_response_test.json162
-rw-r--r--cli/tests/testdata/lsp/completion_request_params_optional.json13
-rw-r--r--cli/tests/testdata/lsp/completion_request_response_empty.json38
-rw-r--r--cli/tests/testdata/lsp/completion_resolve_params.json14
-rw-r--r--cli/tests/testdata/lsp/completion_resolve_params_optional.json15
-rw-r--r--cli/tests/testdata/lsp/completion_resolve_params_registry.json20
-rw-r--r--cli/tests/testdata/lsp/completion_resolve_response.json11
-rw-r--r--cli/tests/testdata/lsp/completion_resolve_response_registry.json20
-rw-r--r--cli/tests/testdata/lsp/diagnostics_deno_deps.json25
-rw-r--r--cli/tests/testdata/lsp/diagnostics_deno_types.json101
-rw-r--r--cli/tests/testdata/lsp/did_open_params_deno_types.json8
-rw-r--r--cli/tests/testdata/lsp/did_open_params_doc_symbol.json8
-rw-r--r--cli/tests/testdata/lsp/did_open_params_import_hover.json8
-rw-r--r--cli/tests/testdata/lsp/did_open_params_large.json8
-rw-r--r--cli/tests/testdata/lsp/did_open_params_semantic_tokens.json8
-rw-r--r--cli/tests/testdata/lsp/did_open_params_test_code_lens.json8
-rw-r--r--cli/tests/testdata/lsp/document_symbol_response.json371
-rw-r--r--cli/tests/testdata/lsp/formatting_mbc_response.json54
-rw-r--r--cli/tests/testdata/lsp/import-map.json5
-rw-r--r--cli/tests/testdata/lsp/incoming_calls_params.json28
-rw-r--r--cli/tests/testdata/lsp/incoming_calls_response.json42
-rw-r--r--cli/tests/testdata/lsp/initialize_params.json65
-rw-r--r--cli/tests/testdata/lsp/initialize_params_bad_config_option.json65
-rw-r--r--cli/tests/testdata/lsp/initialize_params_ca_no_disabled.json64
-rw-r--r--cli/tests/testdata/lsp/initialize_params_code_lens_test.json59
-rw-r--r--cli/tests/testdata/lsp/initialize_params_code_lens_test_disabled.json64
-rw-r--r--cli/tests/testdata/lsp/initialize_params_did_config_change.json65
-rw-r--r--cli/tests/testdata/lsp/initialize_params_disabled.json63
-rw-r--r--cli/tests/testdata/lsp/initialize_params_registry.json65
-rw-r--r--cli/tests/testdata/lsp/initialize_params_unstable.json63
-rw-r--r--cli/tests/testdata/lsp/lib.tsconfig.json5
-rw-r--r--cli/tests/testdata/lsp/outgoing_calls_params.json28
-rw-r--r--cli/tests/testdata/lsp/outgoing_calls_response.json42
-rw-r--r--cli/tests/testdata/lsp/prepare_call_hierarchy_response.json28
-rw-r--r--cli/tests/testdata/lsp/registries/a_latest.json4
-rw-r--r--cli/tests/testdata/lsp/registries/a_v1.0.0.json4
-rw-r--r--cli/tests/testdata/lsp/registries/a_v1.0.1.json4
-rw-r--r--cli/tests/testdata/lsp/registries/a_v2.0.0.json4
-rw-r--r--cli/tests/testdata/lsp/registries/a_versions.json5
-rw-r--r--cli/tests/testdata/lsp/registries/b_latest.json4
-rw-r--r--cli/tests/testdata/lsp/registries/b_v0.0.1.json4
-rw-r--r--cli/tests/testdata/lsp/registries/b_v0.0.2.json4
-rw-r--r--cli/tests/testdata/lsp/registries/b_v0.0.3.json4
-rw-r--r--cli/tests/testdata/lsp/registries/b_versions.json5
-rw-r--r--cli/tests/testdata/lsp/registries/deno-import-intellisense.json35
-rw-r--r--cli/tests/testdata/lsp/registries/modules.json4
-rw-r--r--cli/tests/testdata/lsp/rename_response.json38
-rw-r--r--cli/tests/testdata/lsp/selection_range_response.json86
-rw-r--r--cli/tests/testdata/lsp/types.tsconfig.json7
74 files changed, 3249 insertions, 0 deletions
diff --git a/cli/tests/testdata/lsp/a.d.ts b/cli/tests/testdata/lsp/a.d.ts
new file mode 100644
index 000000000..7f587e144
--- /dev/null
+++ b/cli/tests/testdata/lsp/a.d.ts
@@ -0,0 +1 @@
+declare var a: string;
diff --git a/cli/tests/testdata/lsp/b.d.ts b/cli/tests/testdata/lsp/b.d.ts
new file mode 100644
index 000000000..9d4b96cb8
--- /dev/null
+++ b/cli/tests/testdata/lsp/b.d.ts
@@ -0,0 +1 @@
+declare var b: string;
diff --git a/cli/tests/testdata/lsp/code_action_ignore_lint_params.json b/cli/tests/testdata/lsp/code_action_ignore_lint_params.json
new file mode 100644
index 000000000..7711812fd
--- /dev/null
+++ b/cli/tests/testdata/lsp/code_action_ignore_lint_params.json
@@ -0,0 +1,39 @@
+{
+ "textDocument": {
+ "uri": "file:///a/file.ts"
+ },
+ "range": {
+ "start": {
+ "line": 1,
+ "character": 5
+ },
+ "end": {
+ "line": 1,
+ "character": 12
+ }
+ },
+ "context": {
+ "diagnostics": [
+ {
+ "range": {
+ "start": {
+ "line": 1,
+ "character": 5
+ },
+ "end": {
+ "line": 1,
+ "character": 12
+ }
+ },
+ "severity": 1,
+ "code": "prefer-const",
+ "source": "deno-lint",
+ "message": "'message' is never reassigned\nUse 'const' instead",
+ "relatedInformation": []
+ }
+ ],
+ "only": [
+ "quickfix"
+ ]
+ }
+}
diff --git a/cli/tests/testdata/lsp/code_action_ignore_lint_response.json b/cli/tests/testdata/lsp/code_action_ignore_lint_response.json
new file mode 100644
index 000000000..f5c24ec21
--- /dev/null
+++ b/cli/tests/testdata/lsp/code_action_ignore_lint_response.json
@@ -0,0 +1,62 @@
+[
+ {
+ "title": "Disable prefer-const for this line",
+ "kind": "quickfix",
+ "diagnostics": [
+ {
+ "range": {
+ "start": { "line": 1, "character": 5 },
+ "end": { "line": 1, "character": 12 }
+ },
+ "severity": 1,
+ "code": "prefer-const",
+ "source": "deno-lint",
+ "message": "'message' is never reassigned\nUse 'const' instead",
+ "relatedInformation": []
+ }
+ ],
+ "edit": {
+ "changes": {
+ "file:///a/file.ts": [
+ {
+ "range": {
+ "start": { "line": 1, "character": 0 },
+ "end": { "line": 1, "character": 0 }
+ },
+ "newText": "// deno-lint-ignore prefer-const\n"
+ }
+ ]
+ }
+ }
+ },
+ {
+ "title": "Ignore lint errors for the entire file",
+ "kind": "quickfix",
+ "diagnostics": [
+ {
+ "range": {
+ "start": { "line": 1, "character": 5 },
+ "end": { "line": 1, "character": 12 }
+ },
+ "severity": 1,
+ "code": "prefer-const",
+ "source": "deno-lint",
+ "message": "'message' is never reassigned\nUse 'const' instead",
+ "relatedInformation": []
+ }
+ ],
+ "edit": {
+ "changes": {
+ "file:///a/file.ts": [
+ {
+ "range": {
+ "start": { "line": 0, "character": 0 },
+ "end": { "line": 0, "character": 0 }
+ },
+ "newText": "// deno-lint-ignore-file\n"
+ }
+ ]
+ }
+ }
+ }
+]
diff --git a/cli/tests/testdata/lsp/code_action_params.json b/cli/tests/testdata/lsp/code_action_params.json
new file mode 100644
index 000000000..d026d61f6
--- /dev/null
+++ b/cli/tests/testdata/lsp/code_action_params.json
@@ -0,0 +1,39 @@
+{
+ "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/testdata/lsp/code_action_params_cache.json b/cli/tests/testdata/lsp/code_action_params_cache.json
new file mode 100644
index 000000000..61ae555a3
--- /dev/null
+++ b/cli/tests/testdata/lsp/code_action_params_cache.json
@@ -0,0 +1,41 @@
+{
+ "textDocument": {
+ "uri": "file:///a/file.ts"
+ },
+ "range": {
+ "start": {
+ "line": 0,
+ "character": 19
+ },
+ "end": {
+ "line": 0,
+ "character": 49
+ }
+ },
+ "context": {
+ "diagnostics": [
+ {
+ "range": {
+ "start": {
+ "line": 0,
+ "character": 19
+ },
+ "end": {
+ "line": 0,
+ "character": 49
+ }
+ },
+ "severity": 1,
+ "code": "no-cache",
+ "source": "deno",
+ "message": "Unable to load the remote module: \"https://deno.land/x/a/mod.ts\".",
+ "data": {
+ "specifier": "https://deno.land/x/a/mod.ts"
+ }
+ }
+ ],
+ "only": [
+ "quickfix"
+ ]
+ }
+}
diff --git a/cli/tests/testdata/lsp/code_action_params_deadlock.json b/cli/tests/testdata/lsp/code_action_params_deadlock.json
new file mode 100644
index 000000000..be0e317e1
--- /dev/null
+++ b/cli/tests/testdata/lsp/code_action_params_deadlock.json
@@ -0,0 +1,38 @@
+{
+ "textDocument": {
+ "uri": "file:///a/file.ts"
+ },
+ "range": {
+ "start": {
+ "line": 441,
+ "character": 33
+ },
+ "end": {
+ "line": 441,
+ "character": 42
+ }
+ },
+ "context": {
+ "diagnostics": [
+ {
+ "range": {
+ "start": {
+ "line": 441,
+ "character": 33
+ },
+ "end": {
+ "line": 441,
+ "character": 42
+ }
+ },
+ "severity": 1,
+ "code": 7031,
+ "source": "deno-ts",
+ "message": "Binding element 'debugFlag' implicitly has an 'any' type."
+ }
+ ],
+ "only": [
+ "quickfix"
+ ]
+ }
+}
diff --git a/cli/tests/testdata/lsp/code_action_params_imports.json b/cli/tests/testdata/lsp/code_action_params_imports.json
new file mode 100644
index 000000000..7a5824923
--- /dev/null
+++ b/cli/tests/testdata/lsp/code_action_params_imports.json
@@ -0,0 +1,54 @@
+{
+ "textDocument": {
+ "uri": "file:///a/file01.ts"
+ },
+ "range": {
+ "start": {
+ "line": 1,
+ "character": 12
+ },
+ "end": {
+ "line": 1,
+ "character": 15
+ }
+ },
+ "context": {
+ "diagnostics": [
+ {
+ "range": {
+ "start": {
+ "line": 1,
+ "character": 12
+ },
+ "end": {
+ "line": 1,
+ "character": 15
+ }
+ },
+ "severity": 1,
+ "code": 2304,
+ "source": "deno-ts",
+ "message": "Cannot find name 'abc'."
+ },
+ {
+ "range": {
+ "start": {
+ "line": 2,
+ "character": 12
+ },
+ "end": {
+ "line": 2,
+ "character": 15
+ }
+ },
+ "severity": 1,
+ "code": 2304,
+ "source": "deno-ts",
+ "message": "Cannot find name 'def'."
+ }
+ ],
+ "only": [
+ "quickfix"
+ ]
+ }
+}
diff --git a/cli/tests/testdata/lsp/code_action_params_refactor.json b/cli/tests/testdata/lsp/code_action_params_refactor.json
new file mode 100644
index 000000000..121c400ed
--- /dev/null
+++ b/cli/tests/testdata/lsp/code_action_params_refactor.json
@@ -0,0 +1,21 @@
+{
+ "textDocument": {
+ "uri": "file:///a/file.ts"
+ },
+ "range": {
+ "start": {
+ "line": 0,
+ "character": 0
+ },
+ "end": {
+ "line": 1,
+ "character": 0
+ }
+ },
+ "context": {
+ "diagnostics": [],
+ "only": [
+ "refactor"
+ ]
+ }
+}
diff --git a/cli/tests/testdata/lsp/code_action_resolve_params.json b/cli/tests/testdata/lsp/code_action_resolve_params.json
new file mode 100644
index 000000000..50c1f9a43
--- /dev/null
+++ b/cli/tests/testdata/lsp/code_action_resolve_params.json
@@ -0,0 +1,27 @@
+{
+ "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": []
+ }
+ ],
+ "data": {
+ "specifier": "file:///a/file.ts",
+ "fixId": "fixAwaitInSyncFunction"
+ }
+}
diff --git a/cli/tests/testdata/lsp/code_action_resolve_params_imports.json b/cli/tests/testdata/lsp/code_action_resolve_params_imports.json
new file mode 100644
index 000000000..60178bbfe
--- /dev/null
+++ b/cli/tests/testdata/lsp/code_action_resolve_params_imports.json
@@ -0,0 +1,26 @@
+{
+ "title": "Add all missing imports",
+ "kind": "quickfix",
+ "diagnostics": [
+ {
+ "range": {
+ "start": {
+ "line": 1,
+ "character": 12
+ },
+ "end": {
+ "line": 1,
+ "character": 15
+ }
+ },
+ "severity": 1,
+ "code": 2304,
+ "source": "deno-ts",
+ "message": "Cannot find name 'abc'."
+ }
+ ],
+ "data": {
+ "specifier": "file:///a/file01.ts",
+ "fixId": "fixMissingImport"
+ }
+}
diff --git a/cli/tests/testdata/lsp/code_action_resolve_params_refactor.json b/cli/tests/testdata/lsp/code_action_resolve_params_refactor.json
new file mode 100644
index 000000000..d4bb3bd81
--- /dev/null
+++ b/cli/tests/testdata/lsp/code_action_resolve_params_refactor.json
@@ -0,0 +1,20 @@
+{
+ "title": "Extract to interface",
+ "kind": "refactor.extract.interface",
+ "isPreferred": true,
+ "data": {
+ "specifier": "file:///a/file.ts",
+ "range": {
+ "start": {
+ "line": 0,
+ "character": 7
+ },
+ "end": {
+ "line": 0,
+ "character": 33
+ }
+ },
+ "refactorName": "Extract type",
+ "actionName": "Extract to interface"
+ }
+}
diff --git a/cli/tests/testdata/lsp/code_action_resolve_response.json b/cli/tests/testdata/lsp/code_action_resolve_response.json
new file mode 100644
index 000000000..e3f5b3f0e
--- /dev/null
+++ b/cli/tests/testdata/lsp/code_action_resolve_response.json
@@ -0,0 +1,91 @@
+{
+ "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>"
+ }
+ ]
+ }
+ ]
+ },
+ "data": {
+ "specifier": "file:///a/file.ts",
+ "fixId": "fixAwaitInSyncFunction"
+ }
+}
diff --git a/cli/tests/testdata/lsp/code_action_resolve_response_imports.json b/cli/tests/testdata/lsp/code_action_resolve_response_imports.json
new file mode 100644
index 000000000..6621c501f
--- /dev/null
+++ b/cli/tests/testdata/lsp/code_action_resolve_response_imports.json
@@ -0,0 +1,51 @@
+{
+ "title": "Add all missing imports",
+ "kind": "quickfix",
+ "diagnostics": [
+ {
+ "range": {
+ "start": {
+ "line": 1,
+ "character": 12
+ },
+ "end": {
+ "line": 1,
+ "character": 15
+ }
+ },
+ "severity": 1,
+ "code": 2304,
+ "source": "deno-ts",
+ "message": "Cannot find name 'abc'."
+ }
+ ],
+ "edit": {
+ "documentChanges": [
+ {
+ "textDocument": {
+ "uri": "file:///a/file01.ts",
+ "version": 1
+ },
+ "edits": [
+ {
+ "range": {
+ "start": {
+ "line": 0,
+ "character": 0
+ },
+ "end": {
+ "line": 0,
+ "character": 0
+ }
+ },
+ "newText": "import { abc,def } from \"./file00.ts\";\n"
+ }
+ ]
+ }
+ ]
+ },
+ "data": {
+ "specifier": "file:///a/file01.ts",
+ "fixId": "fixMissingImport"
+ }
+}
diff --git a/cli/tests/testdata/lsp/code_action_resolve_response_refactor.json b/cli/tests/testdata/lsp/code_action_resolve_response_refactor.json
new file mode 100644
index 000000000..721a76a6b
--- /dev/null
+++ b/cli/tests/testdata/lsp/code_action_resolve_response_refactor.json
@@ -0,0 +1,58 @@
+{
+ "title": "Extract to interface",
+ "kind": "refactor.extract.interface",
+ "edit": {
+ "documentChanges": [
+ {
+ "textDocument": {
+ "uri": "file:///a/file.ts",
+ "version": 1
+ },
+ "edits": [
+ {
+ "range": {
+ "start": {
+ "line": 0,
+ "character": 0
+ },
+ "end": {
+ "line": 0,
+ "character": 0
+ }
+ },
+ "newText": "interface NewType {\n a?: number;\n b?: string;\n}\n\n"
+ },
+ {
+ "range": {
+ "start": {
+ "line": 0,
+ "character": 7
+ },
+ "end": {
+ "line": 0,
+ "character": 33
+ }
+ },
+ "newText": "NewType"
+ }
+ ]
+ }
+ ]
+ },
+ "isPreferred": true,
+ "data": {
+ "specifier": "file:///a/file.ts",
+ "range": {
+ "start": {
+ "line": 0,
+ "character": 7
+ },
+ "end": {
+ "line": 0,
+ "character": 33
+ }
+ },
+ "refactorName": "Extract type",
+ "actionName": "Extract to interface"
+ }
+}
diff --git a/cli/tests/testdata/lsp/code_action_response.json b/cli/tests/testdata/lsp/code_action_response.json
new file mode 100644
index 000000000..ab30898f8
--- /dev/null
+++ b/cli/tests/testdata/lsp/code_action_response.json
@@ -0,0 +1,90 @@
+[
+ {
+ "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": []
+ }
+ ],
+ "data": {
+ "specifier": "file:///a/file.ts",
+ "fixId": "fixAwaitInSyncFunction"
+ }
+ }
+]
diff --git a/cli/tests/testdata/lsp/code_action_response_cache.json b/cli/tests/testdata/lsp/code_action_response_cache.json
new file mode 100644
index 000000000..c56b35023
--- /dev/null
+++ b/cli/tests/testdata/lsp/code_action_response_cache.json
@@ -0,0 +1,36 @@
+[
+ {
+ "title": "Cache \"https://deno.land/x/a/mod.ts\" and its dependencies.",
+ "kind": "quickfix",
+ "diagnostics": [
+ {
+ "range": {
+ "start": {
+ "line": 0,
+ "character": 19
+ },
+ "end": {
+ "line": 0,
+ "character": 49
+ }
+ },
+ "severity": 1,
+ "code": "no-cache",
+ "source": "deno",
+ "message": "Unable to load the remote module: \"https://deno.land/x/a/mod.ts\".",
+ "data": {
+ "specifier": "https://deno.land/x/a/mod.ts"
+ }
+ }
+ ],
+ "command": {
+ "title": "",
+ "command": "deno.cache",
+ "arguments": [
+ [
+ "https://deno.land/x/a/mod.ts"
+ ]
+ ]
+ }
+ }
+]
diff --git a/cli/tests/testdata/lsp/code_action_response_imports.json b/cli/tests/testdata/lsp/code_action_response_imports.json
new file mode 100644
index 000000000..e4d926bdd
--- /dev/null
+++ b/cli/tests/testdata/lsp/code_action_response_imports.json
@@ -0,0 +1,242 @@
+[
+ {
+ "title": "Import 'abc' from module \"./file00.ts\"",
+ "kind": "quickfix",
+ "diagnostics": [
+ {
+ "range": {
+ "start": {
+ "line": 1,
+ "character": 12
+ },
+ "end": {
+ "line": 1,
+ "character": 15
+ }
+ },
+ "severity": 1,
+ "code": 2304,
+ "source": "deno-ts",
+ "message": "Cannot find name 'abc'."
+ }
+ ],
+ "edit": {
+ "documentChanges": [
+ {
+ "textDocument": {
+ "uri": "file:///a/file01.ts",
+ "version": 1
+ },
+ "edits": [
+ {
+ "range": {
+ "start": {
+ "line": 0,
+ "character": 0
+ },
+ "end": {
+ "line": 0,
+ "character": 0
+ }
+ },
+ "newText": "import { abc } from \"./file00.ts\";\n"
+ }
+ ]
+ }
+ ]
+ }
+ },
+ {
+ "title": "Add all missing imports",
+ "kind": "quickfix",
+ "diagnostics": [
+ {
+ "range": {
+ "start": {
+ "line": 1,
+ "character": 12
+ },
+ "end": {
+ "line": 1,
+ "character": 15
+ }
+ },
+ "severity": 1,
+ "code": 2304,
+ "source": "deno-ts",
+ "message": "Cannot find name 'abc'."
+ }
+ ],
+ "data": {
+ "specifier": "file:///a/file01.ts",
+ "fixId": "fixMissingImport"
+ }
+ },
+ {
+ "title": "Add missing function declaration 'abc'",
+ "kind": "quickfix",
+ "diagnostics": [
+ {
+ "range": {
+ "start": {
+ "line": 1,
+ "character": 12
+ },
+ "end": {
+ "line": 1,
+ "character": 15
+ }
+ },
+ "severity": 1,
+ "code": 2304,
+ "source": "deno-ts",
+ "message": "Cannot find name 'abc'."
+ }
+ ],
+ "edit": {
+ "documentChanges": [
+ {
+ "textDocument": {
+ "uri": "file:///a/file01.ts",
+ "version": 1
+ },
+ "edits": [
+ {
+ "range": {
+ "start": {
+ "line": 3,
+ "character": 0
+ },
+ "end": {
+ "line": 3,
+ "character": 0
+ }
+ },
+ "newText": "\nfunction abc(abc: any) {\nthrow new Error(\"Function not implemented.\");\n}\n"
+ }
+ ]
+ }
+ ]
+ }
+ },
+ {
+ "title": "Import 'def' from module \"./file00.ts\"",
+ "kind": "quickfix",
+ "diagnostics": [
+ {
+ "range": {
+ "start": {
+ "line": 2,
+ "character": 12
+ },
+ "end": {
+ "line": 2,
+ "character": 15
+ }
+ },
+ "severity": 1,
+ "code": 2304,
+ "source": "deno-ts",
+ "message": "Cannot find name 'def'."
+ }
+ ],
+ "edit": {
+ "documentChanges": [
+ {
+ "textDocument": {
+ "uri": "file:///a/file01.ts",
+ "version": 1
+ },
+ "edits": [
+ {
+ "range": {
+ "start": {
+ "line": 0,
+ "character": 0
+ },
+ "end": {
+ "line": 0,
+ "character": 0
+ }
+ },
+ "newText": "import { def } from \"./file00.ts\";\n"
+ }
+ ]
+ }
+ ]
+ }
+ },
+ {
+ "title": "Add missing function declaration 'def'",
+ "kind": "quickfix",
+ "diagnostics": [
+ {
+ "range": {
+ "start": {
+ "line": 2,
+ "character": 12
+ },
+ "end": {
+ "line": 2,
+ "character": 15
+ }
+ },
+ "severity": 1,
+ "code": 2304,
+ "source": "deno-ts",
+ "message": "Cannot find name 'def'."
+ }
+ ],
+ "edit": {
+ "documentChanges": [
+ {
+ "textDocument": {
+ "uri": "file:///a/file01.ts",
+ "version": 1
+ },
+ "edits": [
+ {
+ "range": {
+ "start": {
+ "line": 3,
+ "character": 0
+ },
+ "end": {
+ "line": 3,
+ "character": 0
+ }
+ },
+ "newText": "\nfunction def(def: any) {\nthrow new Error(\"Function not implemented.\");\n}\n"
+ }
+ ]
+ }
+ ]
+ }
+ },
+ {
+ "title": "Add all missing function declarations",
+ "kind": "quickfix",
+ "diagnostics": [
+ {
+ "range": {
+ "start": {
+ "line": 1,
+ "character": 12
+ },
+ "end": {
+ "line": 1,
+ "character": 15
+ }
+ },
+ "severity": 1,
+ "code": 2304,
+ "source": "deno-ts",
+ "message": "Cannot find name 'abc'."
+ }
+ ],
+ "data": {
+ "specifier": "file:///a/file01.ts",
+ "fixId": "fixMissingFunctionDeclaration"
+ }
+ }
+]
diff --git a/cli/tests/testdata/lsp/code_action_response_no_disabled.json b/cli/tests/testdata/lsp/code_action_response_no_disabled.json
new file mode 100644
index 000000000..c69bd1120
--- /dev/null
+++ b/cli/tests/testdata/lsp/code_action_response_no_disabled.json
@@ -0,0 +1,22 @@
+[
+ {
+ "title": "Move to a new file",
+ "kind": "refactor.move.newFile",
+ "isPreferred": false,
+ "data": {
+ "specifier": "file:///a/file.ts",
+ "range": {
+ "start": {
+ "line": 0,
+ "character": 0
+ },
+ "end": {
+ "line": 14,
+ "character": 0
+ }
+ },
+ "refactorName": "Move to a new file",
+ "actionName": "Move to a new file"
+ }
+ }
+]
diff --git a/cli/tests/testdata/lsp/code_action_response_refactor.json b/cli/tests/testdata/lsp/code_action_response_refactor.json
new file mode 100644
index 000000000..a9fbd2827
--- /dev/null
+++ b/cli/tests/testdata/lsp/code_action_response_refactor.json
@@ -0,0 +1,177 @@
+[
+ {
+ "title": "Extract to function in global scope",
+ "kind": "refactor.extract.function",
+ "isPreferred": false,
+ "data": {
+ "specifier": "file:///a/file.ts",
+ "range": {
+ "start": {
+ "line": 0,
+ "character": 0
+ },
+ "end": {
+ "line": 1,
+ "character": 0
+ }
+ },
+ "refactorName": "Extract Symbol",
+ "actionName": "function_scope_0"
+ }
+ },
+ {
+ "title": "Extract to constant in enclosing scope",
+ "kind": "refactor.extract.constant",
+ "isPreferred": false,
+ "data": {
+ "specifier": "file:///a/file.ts",
+ "range": {
+ "start": {
+ "line": 0,
+ "character": 0
+ },
+ "end": {
+ "line": 1,
+ "character": 0
+ }
+ },
+ "refactorName": "Extract Symbol",
+ "actionName": "constant_scope_0"
+ }
+ },
+ {
+ "title": "Move to a new file",
+ "kind": "refactor.move.newFile",
+ "isPreferred": false,
+ "data": {
+ "specifier": "file:///a/file.ts",
+ "range": {
+ "start": {
+ "line": 0,
+ "character": 0
+ },
+ "end": {
+ "line": 1,
+ "character": 0
+ }
+ },
+ "refactorName": "Move to a new file",
+ "actionName": "Move to a new file"
+ }
+ },
+ {
+ "title": "Convert default export to named export",
+ "kind": "refactor.rewrite.export.named",
+ "isPreferred": false,
+ "disabled": {
+ "reason": "This file already has a default export"
+ },
+ "data": {
+ "specifier": "file:///a/file.ts",
+ "range": {
+ "start": {
+ "line": 0,
+ "character": 0
+ },
+ "end": {
+ "line": 1,
+ "character": 0
+ }
+ },
+ "refactorName": "Convert export",
+ "actionName": "Convert default export to named export"
+ }
+ },
+ {
+ "title": "Convert named export to default export",
+ "kind": "refactor.rewrite.export.default",
+ "isPreferred": false,
+ "disabled": {
+ "reason": "This file already has a default export"
+ },
+ "data": {
+ "specifier": "file:///a/file.ts",
+ "range": {
+ "start": {
+ "line": 0,
+ "character": 0
+ },
+ "end": {
+ "line": 1,
+ "character": 0
+ }
+ },
+ "refactorName": "Convert export",
+ "actionName": "Convert named export to default export"
+ }
+ },
+ {
+ "title": "Convert namespace import to named imports",
+ "kind": "refactor.rewrite.import.named",
+ "isPreferred": false,
+ "disabled": {
+ "reason": "Selection is not an import declaration."
+ },
+ "data": {
+ "specifier": "file:///a/file.ts",
+ "range": {
+ "start": {
+ "line": 0,
+ "character": 0
+ },
+ "end": {
+ "line": 1,
+ "character": 0
+ }
+ },
+ "refactorName": "Convert import",
+ "actionName": "Convert namespace import to named imports"
+ }
+ },
+ {
+ "title": "Convert named imports to namespace import",
+ "kind": "refactor.rewrite.import.namespace",
+ "isPreferred": false,
+ "disabled": {
+ "reason": "Selection is not an import declaration."
+ },
+ "data": {
+ "specifier": "file:///a/file.ts",
+ "range": {
+ "start": {
+ "line": 0,
+ "character": 0
+ },
+ "end": {
+ "line": 1,
+ "character": 0
+ }
+ },
+ "refactorName": "Convert import",
+ "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"
+ }
+ }
+]
diff --git a/cli/tests/testdata/lsp/code_lens_resolve_response.json b/cli/tests/testdata/lsp/code_lens_resolve_response.json
new file mode 100644
index 000000000..1400eb4e6
--- /dev/null
+++ b/cli/tests/testdata/lsp/code_lens_resolve_response.json
@@ -0,0 +1,38 @@
+{
+ "range": {
+ "start": {
+ "line": 0,
+ "character": 6
+ },
+ "end": {
+ "line": 0,
+ "character": 7
+ }
+ },
+ "command": {
+ "title": "1 reference",
+ "command": "deno.showReferences",
+ "arguments": [
+ "file:///a/file.ts",
+ {
+ "line": 0,
+ "character": 6
+ },
+ [
+ {
+ "uri": "file:///a/file.ts",
+ "range": {
+ "start": {
+ "line": 12,
+ "character": 14
+ },
+ "end": {
+ "line": 12,
+ "character": 15
+ }
+ }
+ }
+ ]
+ ]
+ }
+}
diff --git a/cli/tests/testdata/lsp/code_lens_resolve_response_impl.json b/cli/tests/testdata/lsp/code_lens_resolve_response_impl.json
new file mode 100644
index 000000000..cabf2f833
--- /dev/null
+++ b/cli/tests/testdata/lsp/code_lens_resolve_response_impl.json
@@ -0,0 +1,38 @@
+{
+ "range": {
+ "start": {
+ "line": 0,
+ "character": 10
+ },
+ "end": {
+ "line": 0,
+ "character": 11
+ }
+ },
+ "command": {
+ "title": "1 implementation",
+ "command": "deno.showReferences",
+ "arguments": [
+ "file:///a/file.ts",
+ {
+ "line": 0,
+ "character": 10
+ },
+ [
+ {
+ "uri": "file:///a/file.ts",
+ "range": {
+ "start": {
+ "line": 4,
+ "character": 6
+ },
+ "end": {
+ "line": 4,
+ "character": 7
+ }
+ }
+ }
+ ]
+ ]
+ }
+}
diff --git a/cli/tests/testdata/lsp/code_lens_response.json b/cli/tests/testdata/lsp/code_lens_response.json
new file mode 100644
index 000000000..e3a87e4be
--- /dev/null
+++ b/cli/tests/testdata/lsp/code_lens_response.json
@@ -0,0 +1,34 @@
+[
+ {
+ "range": {
+ "start": {
+ "line": 0,
+ "character": 6
+ },
+ "end": {
+ "line": 0,
+ "character": 7
+ }
+ },
+ "data": {
+ "specifier": "file:///a/file.ts",
+ "source": "references"
+ }
+ },
+ {
+ "range": {
+ "start": {
+ "line": 1,
+ "character": 2
+ },
+ "end": {
+ "line": 1,
+ "character": 3
+ }
+ },
+ "data": {
+ "specifier": "file:///a/file.ts",
+ "source": "references"
+ }
+ }
+]
diff --git a/cli/tests/testdata/lsp/code_lens_response_changed.json b/cli/tests/testdata/lsp/code_lens_response_changed.json
new file mode 100644
index 000000000..b0073a23f
--- /dev/null
+++ b/cli/tests/testdata/lsp/code_lens_response_changed.json
@@ -0,0 +1,50 @@
+[
+ {
+ "range": {
+ "start": {
+ "line": 0,
+ "character": 10
+ },
+ "end": {
+ "line": 0,
+ "character": 11
+ }
+ },
+ "data": {
+ "specifier": "file:///a/file.ts",
+ "source": "implementations"
+ }
+ },
+ {
+ "range": {
+ "start": {
+ "line": 0,
+ "character": 10
+ },
+ "end": {
+ "line": 0,
+ "character": 11
+ }
+ },
+ "data": {
+ "specifier": "file:///a/file.ts",
+ "source": "references"
+ }
+ },
+ {
+ "range": {
+ "start": {
+ "line": 4,
+ "character": 6
+ },
+ "end": {
+ "line": 4,
+ "character": 7
+ }
+ },
+ "data": {
+ "specifier": "file:///a/file.ts",
+ "source": "references"
+ }
+ }
+]
diff --git a/cli/tests/testdata/lsp/code_lens_response_impl.json b/cli/tests/testdata/lsp/code_lens_response_impl.json
new file mode 100644
index 000000000..c6e5bd92d
--- /dev/null
+++ b/cli/tests/testdata/lsp/code_lens_response_impl.json
@@ -0,0 +1,98 @@
+[
+ {
+ "range": {
+ "start": {
+ "line": 0,
+ "character": 10
+ },
+ "end": {
+ "line": 0,
+ "character": 11
+ }
+ },
+ "data": {
+ "specifier": "file:///a/file.ts",
+ "source": "implementations"
+ }
+ },
+ {
+ "range": {
+ "start": {
+ "line": 0,
+ "character": 10
+ },
+ "end": {
+ "line": 0,
+ "character": 11
+ }
+ },
+ "data": {
+ "specifier": "file:///a/file.ts",
+ "source": "references"
+ }
+ },
+ {
+ "range": {
+ "start": {
+ "line": 4,
+ "character": 6
+ },
+ "end": {
+ "line": 4,
+ "character": 7
+ }
+ },
+ "data": {
+ "specifier": "file:///a/file.ts",
+ "source": "references"
+ }
+ },
+ {
+ "range": {
+ "start": {
+ "line": 10,
+ "character": 10
+ },
+ "end": {
+ "line": 10,
+ "character": 11
+ }
+ },
+ "data": {
+ "specifier": "file:///a/file.ts",
+ "source": "implementations"
+ }
+ },
+ {
+ "range": {
+ "start": {
+ "line": 10,
+ "character": 10
+ },
+ "end": {
+ "line": 10,
+ "character": 11
+ }
+ },
+ "data": {
+ "specifier": "file:///a/file.ts",
+ "source": "references"
+ }
+ },
+ {
+ "range": {
+ "start": {
+ "line": 11,
+ "character": 2
+ },
+ "end": {
+ "line": 11,
+ "character": 3
+ }
+ },
+ "data": {
+ "specifier": "file:///a/file.ts",
+ "source": "references"
+ }
+ }
+]
diff --git a/cli/tests/testdata/lsp/code_lens_response_test.json b/cli/tests/testdata/lsp/code_lens_response_test.json
new file mode 100644
index 000000000..b2cb4588a
--- /dev/null
+++ b/cli/tests/testdata/lsp/code_lens_response_test.json
@@ -0,0 +1,162 @@
+[
+ {
+ "range": {
+ "start": {
+ "line": 4,
+ "character": 5
+ },
+ "end": {
+ "line": 4,
+ "character": 9
+ }
+ },
+ "command": {
+ "title": "▶︎ Run Test",
+ "command": "deno.test",
+ "arguments": [
+ "file:///a/file.ts",
+ "test a"
+ ]
+ }
+ },
+ {
+ "range": {
+ "start": {
+ "line": 5,
+ "character": 5
+ },
+ "end": {
+ "line": 5,
+ "character": 9
+ }
+ },
+ "command": {
+ "title": "▶︎ Run Test",
+ "command": "deno.test",
+ "arguments": [
+ "file:///a/file.ts",
+ "test b"
+ ]
+ }
+ },
+ {
+ "range": {
+ "start": {
+ "line": 9,
+ "character": 0
+ },
+ "end": {
+ "line": 9,
+ "character": 4
+ }
+ },
+ "command": {
+ "title": "▶︎ Run Test",
+ "command": "deno.test",
+ "arguments": [
+ "file:///a/file.ts",
+ "test c"
+ ]
+ }
+ },
+ {
+ "range": {
+ "start": {
+ "line": 13,
+ "character": 0
+ },
+ "end": {
+ "line": 13,
+ "character": 4
+ }
+ },
+ "command": {
+ "title": "▶︎ Run Test",
+ "command": "deno.test",
+ "arguments": [
+ "file:///a/file.ts",
+ "test d"
+ ]
+ }
+ },
+ {
+ "range": {
+ "start": {
+ "line": 14,
+ "character": 0
+ },
+ "end": {
+ "line": 14,
+ "character": 5
+ }
+ },
+ "command": {
+ "title": "▶︎ Run Test",
+ "command": "deno.test",
+ "arguments": [
+ "file:///a/file.ts",
+ "test e"
+ ]
+ }
+ },
+ {
+ "range": {
+ "start": {
+ "line": 18,
+ "character": 0
+ },
+ "end": {
+ "line": 18,
+ "character": 5
+ }
+ },
+ "command": {
+ "title": "▶︎ Run Test",
+ "command": "deno.test",
+ "arguments": [
+ "file:///a/file.ts",
+ "test f"
+ ]
+ }
+ },
+ {
+ "range": {
+ "start": {
+ "line": 19,
+ "character": 0
+ },
+ "end": {
+ "line": 19,
+ "character": 5
+ }
+ },
+ "command": {
+ "title": "▶︎ Run Test",
+ "command": "deno.test",
+ "arguments": [
+ "file:///a/file.ts",
+ "test g"
+ ]
+ }
+ },
+ {
+ "range": {
+ "start": {
+ "line": 23,
+ "character": 0
+ },
+ "end": {
+ "line": 23,
+ "character": 5
+ }
+ },
+ "command": {
+ "title": "▶︎ Run Test",
+ "command": "deno.test",
+ "arguments": [
+ "file:///a/file.ts",
+ "test h"
+ ]
+ }
+ }
+]
diff --git a/cli/tests/testdata/lsp/completion_request_params_optional.json b/cli/tests/testdata/lsp/completion_request_params_optional.json
new file mode 100644
index 000000000..1f3c079c7
--- /dev/null
+++ b/cli/tests/testdata/lsp/completion_request_params_optional.json
@@ -0,0 +1,13 @@
+{
+ "textDocument": {
+ "uri": "file:///a/file.ts"
+ },
+ "position": {
+ "line": 8,
+ "character": 4
+ },
+ "context": {
+ "triggerKind": 2,
+ "triggerCharacter": "."
+ }
+}
diff --git a/cli/tests/testdata/lsp/completion_request_response_empty.json b/cli/tests/testdata/lsp/completion_request_response_empty.json
new file mode 100644
index 000000000..272dfb475
--- /dev/null
+++ b/cli/tests/testdata/lsp/completion_request_response_empty.json
@@ -0,0 +1,38 @@
+{
+ "isIncomplete": false,
+ "items": [
+ {
+ "label": ".",
+ "kind": 19,
+ "detail": "(local)",
+ "sortText": "1",
+ "insertText": "."
+ },
+ {
+ "label": "..",
+ "kind": 19,
+ "detail": "(local)",
+ "sortText": "1",
+ "insertText": ".."
+ },
+ {
+ "label": "http://localhost:4545",
+ "kind": 19,
+ "detail": "(registry)",
+ "sortText": "2",
+ "textEdit": {
+ "range": {
+ "start": {
+ "line": 0,
+ "character": 20
+ },
+ "end": {
+ "line": 0,
+ "character": 20
+ }
+ },
+ "newText": "http://localhost:4545"
+ }
+ }
+ ]
+}
diff --git a/cli/tests/testdata/lsp/completion_resolve_params.json b/cli/tests/testdata/lsp/completion_resolve_params.json
new file mode 100644
index 000000000..26231036d
--- /dev/null
+++ b/cli/tests/testdata/lsp/completion_resolve_params.json
@@ -0,0 +1,14 @@
+{
+ "label": "build",
+ "kind": 6,
+ "sortText": "1",
+ "insertTextFormat": 1,
+ "data": {
+ "tsc": {
+ "specifier": "file:///a/file.ts",
+ "position": 5,
+ "name": "build",
+ "useCodeSnippet": false
+ }
+ }
+}
diff --git a/cli/tests/testdata/lsp/completion_resolve_params_optional.json b/cli/tests/testdata/lsp/completion_resolve_params_optional.json
new file mode 100644
index 000000000..cb99bf960
--- /dev/null
+++ b/cli/tests/testdata/lsp/completion_resolve_params_optional.json
@@ -0,0 +1,15 @@
+{
+ "label": "b?",
+ "kind": 5,
+ "sortText": "1",
+ "filterText": "b",
+ "insertText": "b",
+ "data": {
+ "tsc": {
+ "specifier": "file:///a/file.ts",
+ "position": 79,
+ "name": "b",
+ "useCodeSnippet": false
+ }
+ }
+}
diff --git a/cli/tests/testdata/lsp/completion_resolve_params_registry.json b/cli/tests/testdata/lsp/completion_resolve_params_registry.json
new file mode 100644
index 000000000..99a4a048e
--- /dev/null
+++ b/cli/tests/testdata/lsp/completion_resolve_params_registry.json
@@ -0,0 +1,20 @@
+{
+ "label": "v2.0.0",
+ "kind": 19,
+ "detail": "(version)",
+ "sortText": "0000000003",
+ "filterText": "http://localhost:4545/x/a@v2.0.0",
+ "textEdit": {
+ "range": {
+ "start": {
+ "line": 0,
+ "character": 20
+ },
+ "end": {
+ "line": 0,
+ "character": 46
+ }
+ },
+ "newText": "http://localhost:4545/x/a@v2.0.0"
+ }
+}
diff --git a/cli/tests/testdata/lsp/completion_resolve_response.json b/cli/tests/testdata/lsp/completion_resolve_response.json
new file mode 100644
index 000000000..0edbc14ef
--- /dev/null
+++ b/cli/tests/testdata/lsp/completion_resolve_response.json
@@ -0,0 +1,11 @@
+{
+ "label": "build",
+ "kind": 6,
+ "detail": "const Deno.build: {\n target: string;\n arch: \"x86_64\" | \"aarch64\";\n os: \"darwin\" | \"linux\" | \"windows\";\n vendor: string;\n env?: string | undefined;\n}",
+ "documentation": {
+ "kind": "markdown",
+ "value": "Build related information."
+ },
+ "sortText": "1",
+ "insertTextFormat": 1
+}
diff --git a/cli/tests/testdata/lsp/completion_resolve_response_registry.json b/cli/tests/testdata/lsp/completion_resolve_response_registry.json
new file mode 100644
index 000000000..99a4a048e
--- /dev/null
+++ b/cli/tests/testdata/lsp/completion_resolve_response_registry.json
@@ -0,0 +1,20 @@
+{
+ "label": "v2.0.0",
+ "kind": 19,
+ "detail": "(version)",
+ "sortText": "0000000003",
+ "filterText": "http://localhost:4545/x/a@v2.0.0",
+ "textEdit": {
+ "range": {
+ "start": {
+ "line": 0,
+ "character": 20
+ },
+ "end": {
+ "line": 0,
+ "character": 46
+ }
+ },
+ "newText": "http://localhost:4545/x/a@v2.0.0"
+ }
+}
diff --git a/cli/tests/testdata/lsp/diagnostics_deno_deps.json b/cli/tests/testdata/lsp/diagnostics_deno_deps.json
new file mode 100644
index 000000000..ec6cc4f51
--- /dev/null
+++ b/cli/tests/testdata/lsp/diagnostics_deno_deps.json
@@ -0,0 +1,25 @@
+{
+ "uri": "file:///a/file.ts",
+ "diagnostics": [
+ {
+ "range": {
+ "start": {
+ "line": 0,
+ "character": 19
+ },
+ "end": {
+ "line": 0,
+ "character": 49
+ }
+ },
+ "severity": 1,
+ "code": "no-cache",
+ "source": "deno",
+ "message": "Uncached or missing remote URL: \"https://deno.land/x/a/mod.ts\".",
+ "data": {
+ "specifier": "https://deno.land/x/a/mod.ts"
+ }
+ }
+ ],
+ "version": 1
+}
diff --git a/cli/tests/testdata/lsp/diagnostics_deno_types.json b/cli/tests/testdata/lsp/diagnostics_deno_types.json
new file mode 100644
index 000000000..f33945a59
--- /dev/null
+++ b/cli/tests/testdata/lsp/diagnostics_deno_types.json
@@ -0,0 +1,101 @@
+{
+ "uri": "file:///a/file.ts",
+ "diagnostics": [
+ {
+ "range": {
+ "start": {
+ "line": 0,
+ "character": 21
+ },
+ "end": {
+ "line": 0,
+ "character": 51
+ }
+ },
+ "severity": 1,
+ "code": "no-cache",
+ "source": "deno",
+ "message": "Uncached or missing remote URL: \"https://example.com/a/b.d.ts\".",
+ "data": {
+ "specifier": "https://example.com/a/b.d.ts"
+ }
+ },
+ {
+ "range": {
+ "start": {
+ "line": 7,
+ "character": 19
+ },
+ "end": {
+ "line": 7,
+ "character": 47
+ }
+ },
+ "severity": 1,
+ "code": "no-cache",
+ "source": "deno",
+ "message": "Uncached or missing remote URL: \"https://example.com/a/e.js\".",
+ "data": {
+ "specifier": "https://example.com/a/e.js"
+ }
+ },
+ {
+ "range": {
+ "start": {
+ "line": 6,
+ "character": 16
+ },
+ "end": {
+ "line": 6,
+ "character": 44
+ }
+ },
+ "severity": 1,
+ "code": "no-cache",
+ "source": "deno",
+ "message": "Uncached or missing remote URL: \"https://example.com/a/e.d.ts\".",
+ "data": {
+ "specifier": "https://example.com/a/e.d.ts"
+ }
+ },
+ {
+ "range": {
+ "start": {
+ "line": 4,
+ "character": 19
+ },
+ "end": {
+ "line": 4,
+ "character": 47
+ }
+ },
+ "severity": 1,
+ "code": "no-cache",
+ "source": "deno",
+ "message": "Uncached or missing remote URL: \"https://example.com/a/d.js\".",
+ "data": {
+ "specifier": "https://example.com/a/d.js"
+ }
+ },
+ {
+ "range": {
+ "start": {
+ "line": 3,
+ "character": 15
+ },
+ "end": {
+ "line": 3,
+ "character": 43
+ }
+ },
+ "severity": 1,
+ "code": "no-cache",
+ "source": "deno",
+ "message": "Uncached or missing remote URL: \"https://example.com/a/d.d.ts\".",
+ "data": {
+ "specifier": "https://example.com/a/d.d.ts"
+ }
+ }
+ ],
+ "version": 1
+}
diff --git a/cli/tests/testdata/lsp/did_open_params_deno_types.json b/cli/tests/testdata/lsp/did_open_params_deno_types.json
new file mode 100644
index 000000000..6f085d045
--- /dev/null
+++ b/cli/tests/testdata/lsp/did_open_params_deno_types.json
@@ -0,0 +1,8 @@
+{
+ "textDocument": {
+ "uri": "file:///a/file.ts",
+ "languageId": "typescript",
+ "version": 1,
+ "text": "/// <reference types=\"https://example.com/a/b.d.ts\" />\n/// <reference path=\"https://example.com/a/c.ts\"\n\n// @deno-types=https://example.com/a/d.d.ts\nimport * as d from \"https://example.com/a/d.js\";\n\n// @deno-types=\"https://example.com/a/e.d.ts\"\nimport * as e from \"https://example.com/a/e.js\";\n\nconsole.log(d, e);\n"
+ }
+}
diff --git a/cli/tests/testdata/lsp/did_open_params_doc_symbol.json b/cli/tests/testdata/lsp/did_open_params_doc_symbol.json
new file mode 100644
index 000000000..c74877191
--- /dev/null
+++ b/cli/tests/testdata/lsp/did_open_params_doc_symbol.json
@@ -0,0 +1,8 @@
+{
+ "textDocument": {
+ "uri": "file:///a/file.ts",
+ "languageId": "typescript",
+ "version": 1,
+ "text": "interface IFoo {\n foo(): boolean;\n}\n\nclass Bar implements IFoo {\n constructor(public x: number) { }\n foo() { return true; }\n /** @deprecated */\n baz() { return false; }\n get value(): number { return 0; }\n set value(newVavlue: number) { return; }\n static staticBar = new Bar(0);\n private static getStaticBar() { return Bar.staticBar; }\n}\n\nenum Values { value1, value2 }\n\nvar bar: IFoo = new Bar(3);"
+ }
+}
diff --git a/cli/tests/testdata/lsp/did_open_params_import_hover.json b/cli/tests/testdata/lsp/did_open_params_import_hover.json
new file mode 100644
index 000000000..e054eef3e
--- /dev/null
+++ b/cli/tests/testdata/lsp/did_open_params_import_hover.json
@@ -0,0 +1,8 @@
+{
+ "textDocument": {
+ "uri": "file:///a/file.ts",
+ "languageId": "typescript",
+ "version": 1,
+ "text": "import * as a from \"http://127.0.0.1:4545/xTypeScriptTypes.js\";\n// @deno-types=\"http://127.0.0.1:4545/type_definitions/foo.d.ts\"\nimport * as b from \"http://127.0.0.1:4545/type_definitions/foo.js\";\nimport * as c from \"http://127.0.0.1:4545/subdir/type_reference.js\";\nimport * as d from \"http://127.0.0.1:4545/subdir/mod1.ts\";\nimport * as e from \"data:application/typescript;base64,ZXhwb3J0IGNvbnN0IGEgPSAiYSI7CgpleHBvcnQgZW51bSBBIHsKICBBLAogIEIsCiAgQywKfQo=\";\nimport * as f from \"./file_01.ts\";\n\nconsole.log(a, b, c, d, e, f);\n"
+ }
+}
diff --git a/cli/tests/testdata/lsp/did_open_params_large.json b/cli/tests/testdata/lsp/did_open_params_large.json
new file mode 100644
index 000000000..996434c0c
--- /dev/null
+++ b/cli/tests/testdata/lsp/did_open_params_large.json
@@ -0,0 +1,8 @@
+{
+ "textDocument": {
+ "uri": "file:///a/file.ts",
+ "languageId": "javascript",
+ "version": 1,
+ "text": "// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.\n\n// @ts-check\n/// <reference path=\"./compiler.d.ts\" />\n// deno-lint-ignore-file no-undef\n\n// This module is the entry point for \"compiler\" isolate, ie. the one\n// that is created when Deno needs to type check TypeScript, and in some\n// instances convert TypeScript to JavaScript.\n\n// Removes the `__proto__` for security reasons. This intentionally makes\n// Deno non compliant with ECMA-262 Annex B.2.2.1\ndelete Object.prototype.__proto__;\n\n((window) => {\n /** @type {DenoCore} */\n const core = window.Deno.core;\n\n let logDebug = false;\n let logSource = \"JS\";\n\n function setLogDebug(debug, source) {\n logDebug = debug;\n if (source) {\n logSource = source;\n }\n }\n\n function debug(...args) {\n if (logDebug) {\n const stringifiedArgs = args.map((arg) =>\n typeof arg === \"string\" ? arg : JSON.stringify(arg)\n ).join(\" \");\n // adding a non-zero integer value to the end of the debug string causes\n // the message to be printed to stderr instead of stdout, which is better\n // aligned to the behaviour of debug messages\n core.print(`DEBUG ${logSource} - ${stringifiedArgs}\\n`, 1);\n }\n }\n\n function error(...args) {\n const stringifiedArgs = args.map((arg) =>\n typeof arg === \"string\" || arg instanceof Error\n ? String(arg)\n : JSON.stringify(arg)\n ).join(\" \");\n core.print(`ERROR ${logSource} = ${stringifiedArgs}\\n`, 1);\n }\n\n class AssertionError extends Error {\n constructor(msg) {\n super(msg);\n this.name = \"AssertionError\";\n }\n }\n\n function assert(cond, msg = \"Assertion failed.\") {\n if (!cond) {\n throw new AssertionError(msg);\n }\n }\n\n /** @type {Map<string, ts.SourceFile>} */\n const sourceFileCache = new Map();\n\n /** @param {ts.DiagnosticRelatedInformation} diagnostic */\n function fromRelatedInformation({\n start,\n length,\n file,\n messageText: msgText,\n ...ri\n }) {\n let messageText;\n let messageChain;\n if (typeof msgText === \"object\") {\n messageChain = msgText;\n } else {\n messageText = msgText;\n }\n if (start !== undefined && length !== undefined && file) {\n const startPos = file.getLineAndCharacterOfPosition(start);\n const sourceLine = file.getFullText().split(\"\\n\")[startPos.line];\n const fileName = file.fileName;\n return {\n start: startPos,\n end: file.getLineAndCharacterOfPosition(start + length),\n fileName,\n messageChain,\n messageText,\n sourceLine,\n ...ri,\n };\n } else {\n return {\n messageChain,\n messageText,\n ...ri,\n };\n }\n }\n\n /** @param {ts.Diagnostic[]} diagnostics */\n function fromTypeScriptDiagnostic(diagnostics) {\n return diagnostics.map(({ relatedInformation: ri, source, ...diag }) => {\n /** @type {any} */\n const value = fromRelatedInformation(diag);\n value.relatedInformation = ri\n ? ri.map(fromRelatedInformation)\n : undefined;\n value.source = source;\n return value;\n });\n }\n\n // Using incremental compile APIs requires that all\n // paths must be either relative or absolute. Since\n // analysis in Rust operates on fully resolved URLs,\n // it makes sense to use the same scheme here.\n const ASSETS = \"asset:///\";\n const CACHE = \"cache:///\";\n\n /** Diagnostics that are intentionally ignored when compiling TypeScript in\n * Deno, as they provide misleading or incorrect information. */\n const IGNORED_DIAGNOSTICS = [\n // TS1208: All files must be modules when the '--isolatedModules' flag is\n // provided. We can ignore because we guarantee that all files are\n // modules.\n 1208,\n // TS1375: 'await' expressions are only allowed at the top level of a file\n // when that file is a module, but this file has no imports or exports.\n // Consider adding an empty 'export {}' to make this file a module.\n 1375,\n // TS1103: 'for-await-of' statement is only allowed within an async function\n // or async generator.\n 1103,\n // TS2306: File 'file:///Users/rld/src/deno/subdir/amd_like.js' is\n // not a module.\n 2306,\n // TS2691: An import path cannot end with a '.ts' extension. Consider\n // importing 'bad-module' instead.\n 2691,\n // TS2792: Cannot find module. Did you mean to set the 'moduleResolution'\n // option to 'node', or to add aliases to the 'paths' option?\n 2792,\n // TS5009: Cannot find the common subdirectory path for the input files.\n 5009,\n // TS5055: Cannot write file\n // 'http://localhost:4545/subdir/mt_application_x_javascript.j4.js'\n // because it would overwrite input file.\n 5055,\n // TypeScript is overly opinionated that only CommonJS modules kinds can\n // support JSON imports. Allegedly this was fixed in\n // Microsoft/TypeScript#26825 but that doesn't seem to be working here,\n // so we will ignore complaints about this compiler setting.\n 5070,\n // TS7016: Could not find a declaration file for module '...'. '...'\n // implicitly has an 'any' type. This is due to `allowJs` being off by\n // default but importing of a JavaScript module.\n 7016,\n ];\n\n const SNAPSHOT_COMPILE_OPTIONS = {\n esModuleInterop: true,\n jsx: ts.JsxEmit.React,\n module: ts.ModuleKind.ESNext,\n noEmit: true,\n strict: true,\n target: ts.ScriptTarget.ESNext,\n };\n\n class ScriptSnapshot {\n /** @type {string} */\n specifier;\n /** @type {string} */\n version;\n /**\n * @param {string} specifier\n * @param {string} version \n */\n constructor(specifier, version) {\n this.specifier = specifier;\n this.version = version;\n }\n /**\n * @param {number} start \n * @param {number} end \n * @returns {string}\n */\n getText(start, end) {\n const { specifier, version } = this;\n debug(\n `snapshot.getText(${start}, ${end}) specifier: ${specifier} version: ${version}`,\n );\n return core.jsonOpSync(\"op_get_text\", { specifier, version, start, end });\n }\n /**\n * @returns {number}\n */\n getLength() {\n const { specifier, version } = this;\n debug(`snapshot.getLength() specifier: ${specifier} version: ${version}`);\n return core.jsonOpSync(\"op_get_length\", { specifier, version });\n }\n /**\n * @param {ScriptSnapshot} oldSnapshot\n * @returns {ts.TextChangeRange | undefined}\n */\n getChangeRange(oldSnapshot) {\n const { specifier, version } = this;\n const { version: oldVersion } = oldSnapshot;\n const oldLength = oldSnapshot.getLength();\n debug(\n `snapshot.getLength() specifier: ${specifier} oldVersion: ${oldVersion} version: ${version}`,\n );\n return core.jsonOpSync(\n \"op_get_change_range\",\n { specifier, oldLength, oldVersion, version },\n );\n }\n dispose() {\n const { specifier, version } = this;\n debug(`snapshot.dispose() specifier: ${specifier} version: ${version}`);\n core.jsonOpSync(\"op_dispose\", { specifier, version });\n }\n }\n\n /** @type {ts.CompilerOptions} */\n let compilationSettings = {};\n\n /** @type {ts.LanguageService} */\n let languageService;\n\n /** An object literal of the incremental compiler host, which provides the\n * specific \"bindings\" to the Deno environment that tsc needs to work.\n *\n * @type {ts.CompilerHost & ts.LanguageServiceHost} */\n const host = {\n fileExists(fileName) {\n debug(`host.fileExists(\"${fileName}\")`);\n return false;\n },\n readFile(specifier) {\n debug(`host.readFile(\"${specifier}\")`);\n return core.jsonOpSync(\"op_load\", { specifier }).data;\n },\n getSourceFile(\n specifier,\n languageVersion,\n _onError,\n _shouldCreateNewSourceFile,\n ) {\n debug(\n `host.getSourceFile(\"${specifier}\", ${\n ts.ScriptTarget[languageVersion]\n })`,\n );\n let sourceFile = sourceFileCache.get(specifier);\n if (sourceFile) {\n return sourceFile;\n }\n\n /** @type {{ data: string; hash?: string; scriptKind: ts.ScriptKind }} */\n const { data, hash, scriptKind } = core.jsonOpSync(\n \"op_load\",\n { specifier },\n );\n assert(\n data != null,\n `\"data\" is unexpectedly null for \"${specifier}\".`,\n );\n sourceFile = ts.createSourceFile(\n specifier,\n data,\n languageVersion,\n false,\n scriptKind,\n );\n sourceFile.moduleName = specifier;\n sourceFile.version = hash;\n sourceFileCache.set(specifier, sourceFile);\n return sourceFile;\n },\n getDefaultLibFileName() {\n return `${ASSETS}/lib.esnext.d.ts`;\n },\n getDefaultLibLocation() {\n return ASSETS;\n },\n writeFile(fileName, data, _writeByteOrderMark, _onError, sourceFiles) {\n debug(`host.writeFile(\"${fileName}\")`);\n let maybeSpecifiers;\n if (sourceFiles) {\n maybeSpecifiers = sourceFiles.map((sf) => sf.moduleName);\n }\n return core.jsonOpSync(\n \"op_emit\",\n { maybeSpecifiers, fileName, data },\n );\n },\n getCurrentDirectory() {\n return CACHE;\n },\n getCanonicalFileName(fileName) {\n return fileName;\n },\n useCaseSensitiveFileNames() {\n return true;\n },\n getNewLine() {\n return \"\\n\";\n },\n resolveModuleNames(specifiers, base) {\n debug(`host.resolveModuleNames()`);\n debug(` base: ${base}`);\n debug(` specifiers: ${specifiers.join(\", \")}`);\n /** @type {Array<[string, ts.Extension] | undefined>} */\n const resolved = core.jsonOpSync(\"op_resolve\", {\n specifiers,\n base,\n });\n if (resolved) {\n const result = resolved.map((item) => {\n if (item) {\n const [resolvedFileName, extension] = item;\n return {\n resolvedFileName,\n extension,\n isExternalLibraryImport: false,\n };\n }\n return undefined;\n });\n result.length = specifiers.length;\n return result;\n } else {\n return new Array(specifiers.length);\n }\n },\n createHash(data) {\n return core.jsonOpSync(\"op_create_hash\", { data }).hash;\n },\n\n // LanguageServiceHost\n getCompilationSettings() {\n debug(\"host.getCompilationSettings()\");\n return compilationSettings;\n },\n getScriptFileNames() {\n debug(\"host.getScriptFileNames()\");\n return core.jsonOpSync(\"op_script_names\", undefined);\n },\n getScriptVersion(specifier) {\n debug(`host.getScriptVersion(\"${specifier}\")`);\n const sourceFile = sourceFileCache.get(specifier);\n if (sourceFile) {\n return sourceFile.version ?? \"1\";\n }\n return core.jsonOpSync(\"op_script_version\", { specifier });\n },\n getScriptSnapshot(specifier) {\n debug(`host.getScriptSnapshot(\"${specifier}\")`);\n const sourceFile = sourceFileCache.get(specifier);\n if (sourceFile) {\n return {\n getText(start, end) {\n return sourceFile.text.substring(start, end);\n },\n getLength() {\n return sourceFile.text.length;\n },\n getChangeRange() {\n return undefined;\n },\n };\n }\n /** @type {string | undefined} */\n const version = core.jsonOpSync(\"op_script_version\", { specifier });\n if (version != null) {\n return new ScriptSnapshot(specifier, version);\n }\n return undefined;\n },\n };\n\n /** @type {Array<[string, number]>} */\n const stats = [];\n let statsStart = 0;\n\n function performanceStart() {\n stats.length = 0;\n statsStart = Date.now();\n ts.performance.enable();\n }\n\n /**\n * @param {{ program: ts.Program | ts.EmitAndSemanticDiagnosticsBuilderProgram, fileCount?: number }} options \n */\n function performanceProgram({ program, fileCount }) {\n if (program) {\n if (\"getProgram\" in program) {\n program = program.getProgram();\n }\n stats.push([\"Files\", program.getSourceFiles().length]);\n stats.push([\"Nodes\", program.getNodeCount()]);\n stats.push([\"Identifiers\", program.getIdentifierCount()]);\n stats.push([\"Symbols\", program.getSymbolCount()]);\n stats.push([\"Types\", program.getTypeCount()]);\n stats.push([\"Instantiations\", program.getInstantiationCount()]);\n } else if (fileCount != null) {\n stats.push([\"Files\", fileCount]);\n }\n const programTime = ts.performance.getDuration(\"Program\");\n const bindTime = ts.performance.getDuration(\"Bind\");\n const checkTime = ts.performance.getDuration(\"Check\");\n const emitTime = ts.performance.getDuration(\"Emit\");\n stats.push([\"Parse time\", programTime]);\n stats.push([\"Bind time\", bindTime]);\n stats.push([\"Check time\", checkTime]);\n stats.push([\"Emit time\", emitTime]);\n stats.push(\n [\"Total TS time\", programTime + bindTime + checkTime + emitTime],\n );\n }\n\n function performanceEnd() {\n const duration = Date.now() - statsStart;\n stats.push([\"Compile time\", duration]);\n return stats;\n }\n\n /**\n * @typedef {object} Request\n * @property {Record<string, any>} config\n * @property {boolean} debug\n * @property {string[]} rootNames\n */\n\n /** The API that is called by Rust when executing a request.\n * @param {Request} request\n */\n function exec({ config, debug: debugFlag, rootNames }) {\n setLogDebug(debugFlag, \"TS\");\n performanceStart();\n debug(\">>> exec start\", { rootNames });\n debug(config);\n\n const { options, errors: configFileParsingDiagnostics } = ts\n .convertCompilerOptionsFromJson(config, \"\");\n // The `allowNonTsExtensions` is a \"hidden\" compiler option used in VSCode\n // which is not allowed to be passed in JSON, we need it to allow special\n // URLs which Deno supports. So we need to either ignore the diagnostic, or\n // inject it ourselves.\n Object.assign(options, { allowNonTsExtensions: true });\n const program = ts.createIncrementalProgram({\n rootNames,\n options,\n host,\n configFileParsingDiagnostics,\n });\n\n const { diagnostics: emitDiagnostics } = program.emit();\n\n const diagnostics = [\n ...program.getConfigFileParsingDiagnostics(),\n ...program.getSyntacticDiagnostics(),\n ...program.getOptionsDiagnostics(),\n ...program.getGlobalDiagnostics(),\n ...program.getSemanticDiagnostics(),\n ...emitDiagnostics,\n ].filter(({ code }) => !IGNORED_DIAGNOSTICS.includes(code));\n performanceProgram({ program });\n\n core.jsonOpSync(\"op_respond\", {\n diagnostics: fromTypeScriptDiagnostic(diagnostics),\n stats: performanceEnd(),\n });\n debug(\"<<< exec stop\");\n }\n\n /**\n * @param {number} id \n * @param {any} data \n */\n function respond(id, data = null) {\n core.jsonOpSync(\"op_respond\", { id, data });\n }\n\n /**\n * @param {LanguageServerRequest} request \n */\n function serverRequest({ id, ...request }) {\n debug(`serverRequest()`, { id, ...request });\n switch (request.method) {\n case \"configure\": {\n const { options, errors } = ts\n .convertCompilerOptionsFromJson(request.compilerOptions, \"\");\n Object.assign(options, { allowNonTsExtensions: true });\n if (errors.length) {\n debug(ts.formatDiagnostics(errors, host));\n }\n compilationSettings = options;\n return respond(id, true);\n }\n case \"getAsset\": {\n const sourceFile = host.getSourceFile(\n request.specifier,\n ts.ScriptTarget.ESNext,\n );\n return respond(id, sourceFile && sourceFile.text);\n }\n case \"getDiagnostics\": {\n try {\n /** @type {Record<string, any[]>} */\n const diagnosticMap = {};\n for (const specifier of request.specifiers) {\n diagnosticMap[specifier] = fromTypeScriptDiagnostic([\n ...languageService.getSemanticDiagnostics(specifier),\n ...languageService.getSuggestionDiagnostics(specifier),\n ...languageService.getSyntacticDiagnostics(specifier),\n ].filter(({ code }) => !IGNORED_DIAGNOSTICS.includes(code)));\n }\n return respond(id, diagnosticMap);\n } catch (e) {\n if (\"stack\" in e) {\n error(e.stack);\n } else {\n error(e);\n }\n return respond(id, {});\n }\n }\n case \"getQuickInfo\": {\n return respond(\n id,\n languageService.getQuickInfoAtPosition(\n request.specifier,\n request.position,\n ),\n );\n }\n case \"getCompletions\": {\n return respond(\n id,\n languageService.getCompletionsAtPosition(\n request.specifier,\n request.position,\n request.preferences,\n ),\n );\n }\n case \"getDocumentHighlights\": {\n return respond(\n id,\n languageService.getDocumentHighlights(\n request.specifier,\n request.position,\n request.filesToSearch,\n ),\n );\n }\n case \"getReferences\": {\n return respond(\n id,\n languageService.getReferencesAtPosition(\n request.specifier,\n request.position,\n ),\n );\n }\n case \"getDefinition\": {\n return respond(\n id,\n languageService.getDefinitionAndBoundSpan(\n request.specifier,\n request.position,\n ),\n );\n }\n case \"getImplementation\": {\n return respond(\n id,\n languageService.getImplementationAtPosition(\n request.specifier,\n request.position,\n ),\n );\n }\n case \"findRenameLocations\": {\n return respond(\n id,\n languageService.findRenameLocations(\n request.specifier,\n request.position,\n request.findInStrings,\n request.findInComments,\n request.providePrefixAndSuffixTextForRename,\n ),\n );\n }\n default:\n throw new TypeError(\n // @ts-ignore exhausted case statement sets type to never\n `Invalid request method for request: \"${request.method}\" (${id})`,\n );\n }\n }\n\n /** @param {{ debug: boolean; }} init */\n function serverInit({ debug: debugFlag }) {\n if (hasStarted) {\n throw new Error(\"The language server has already been initialized.\");\n }\n hasStarted = true;\n languageService = ts.createLanguageService(host);\n core.ops();\n setLogDebug(debugFlag, \"TSLS\");\n debug(\"serverInit()\");\n }\n\n let hasStarted = false;\n\n /** Startup the runtime environment, setting various flags.\n * @param {{ debugFlag?: boolean; legacyFlag?: boolean; }} msg\n */\n function startup({ debugFlag = false }) {\n if (hasStarted) {\n throw new Error(\"The compiler runtime already started.\");\n }\n hasStarted = true;\n core.ops();\n setLogDebug(!!debugFlag, \"TS\");\n }\n\n // Setup the compiler runtime during the build process.\n core.ops();\n core.registerErrorClass(\"Error\", Error);\n\n // A build time only op that provides some setup information that is used to\n // ensure the snapshot is setup properly.\n /** @type {{ buildSpecifier: string; libs: string[] }} */\n const { buildSpecifier, libs } = core.jsonOpSync(\"op_build_info\", {});\n for (const lib of libs) {\n const specifier = `lib.${lib}.d.ts`;\n // we are using internal APIs here to \"inject\" our custom libraries into\n // tsc, so things like `\"lib\": [ \"deno.ns\" ]` are supported.\n if (!ts.libs.includes(lib)) {\n ts.libs.push(lib);\n ts.libMap.set(lib, `lib.${lib}.d.ts`);\n }\n // we are caching in memory common type libraries that will be re-used by\n // tsc on when the snapshot is restored\n assert(\n host.getSourceFile(`${ASSETS}${specifier}`, ts.ScriptTarget.ESNext),\n );\n }\n // this helps ensure as much as possible is in memory that is re-usable\n // before the snapshotting is done, which helps unsure fast \"startup\" for\n // subsequent uses of tsc in Deno.\n const TS_SNAPSHOT_PROGRAM = ts.createProgram({\n rootNames: [buildSpecifier],\n options: SNAPSHOT_COMPILE_OPTIONS,\n host,\n });\n ts.getPreEmitDiagnostics(TS_SNAPSHOT_PROGRAM);\n\n // exposes the two functions that are called by `tsc::exec()` when type\n // checking TypeScript.\n globalThis.startup = startup;\n globalThis.exec = exec;\n\n // exposes the functions that are called when the compiler is used as a\n // language service.\n globalThis.serverInit = serverInit;\n globalThis.serverRequest = serverRequest;\n})(this);\n"
+ }
+}
diff --git a/cli/tests/testdata/lsp/did_open_params_semantic_tokens.json b/cli/tests/testdata/lsp/did_open_params_semantic_tokens.json
new file mode 100644
index 000000000..5cf48ae05
--- /dev/null
+++ b/cli/tests/testdata/lsp/did_open_params_semantic_tokens.json
@@ -0,0 +1,8 @@
+{
+ "textDocument": {
+ "uri": "file:///a/file.ts",
+ "languageId": "typescript",
+ "version": 1,
+ "text": "enum Values { value1, value2 }\n\nasync function baz(s: string): Promise<string> {\n const r = s.slice(0);\n return r;\n}\n\ninterface IFoo {\n readonly x: number;\n foo(): boolean;\n}\n\nclass Bar implements IFoo {\n constructor(public readonly x: number) { }\n foo() { return true; }\n static staticBar = new Bar(0);\n private static getStaticBar() { return Bar.staticBar; }\n}\n"
+ }
+}
diff --git a/cli/tests/testdata/lsp/did_open_params_test_code_lens.json b/cli/tests/testdata/lsp/did_open_params_test_code_lens.json
new file mode 100644
index 000000000..dcb9e11f3
--- /dev/null
+++ b/cli/tests/testdata/lsp/did_open_params_test_code_lens.json
@@ -0,0 +1,8 @@
+{
+ "textDocument": {
+ "uri": "file:///a/file.ts",
+ "languageId": "typescript",
+ "version": 1,
+ "text": "const { test } = Deno;\nconst { test: test2 } = Deno;\nconst test3 = Deno.test;\n\nDeno.test(\"test a\", () => {});\nDeno.test({\n name: \"test b\",\n fn() {},\n});\ntest({\n name: \"test c\",\n fn() {},\n});\ntest(\"test d\", () => {});\ntest2({\n name: \"test e\",\n fn() {},\n});\ntest2(\"test f\", () => {});\ntest3({\n name: \"test g\",\n fn() {},\n});\ntest3(\"test h\", () => {});\n"
+ }
+}
diff --git a/cli/tests/testdata/lsp/document_symbol_response.json b/cli/tests/testdata/lsp/document_symbol_response.json
new file mode 100644
index 000000000..89d56ef70
--- /dev/null
+++ b/cli/tests/testdata/lsp/document_symbol_response.json
@@ -0,0 +1,371 @@
+[
+ {
+ "name": "bar",
+ "kind": 13,
+ "range": {
+ "start": {
+ "line": 17,
+ "character": 4
+ },
+ "end": {
+ "line": 17,
+ "character": 26
+ }
+ },
+ "selectionRange": {
+ "start": {
+ "line": 17,
+ "character": 4
+ },
+ "end": {
+ "line": 17,
+ "character": 7
+ }
+ }
+ },
+ {
+ "name": "Bar",
+ "kind": 5,
+ "range": {
+ "start": {
+ "line": 4,
+ "character": 0
+ },
+ "end": {
+ "line": 13,
+ "character": 1
+ }
+ },
+ "selectionRange": {
+ "start": {
+ "line": 4,
+ "character": 6
+ },
+ "end": {
+ "line": 4,
+ "character": 9
+ }
+ },
+ "children": [
+ {
+ "name": "constructor",
+ "kind": 9,
+ "range": {
+ "start": {
+ "line": 5,
+ "character": 2
+ },
+ "end": {
+ "line": 5,
+ "character": 35
+ }
+ },
+ "selectionRange": {
+ "start": {
+ "line": 5,
+ "character": 2
+ },
+ "end": {
+ "line": 5,
+ "character": 35
+ }
+ }
+ },
+ {
+ "name": "baz",
+ "kind": 6,
+ "tags": [
+ 1
+ ],
+ "range": {
+ "start": {
+ "line": 8,
+ "character": 2
+ },
+ "end": {
+ "line": 8,
+ "character": 25
+ }
+ },
+ "selectionRange": {
+ "start": {
+ "line": 8,
+ "character": 2
+ },
+ "end": {
+ "line": 8,
+ "character": 5
+ }
+ }
+ },
+ {
+ "name": "foo",
+ "kind": 6,
+ "range": {
+ "start": {
+ "line": 6,
+ "character": 2
+ },
+ "end": {
+ "line": 6,
+ "character": 24
+ }
+ },
+ "selectionRange": {
+ "start": {
+ "line": 6,
+ "character": 2
+ },
+ "end": {
+ "line": 6,
+ "character": 5
+ }
+ }
+ },
+ {
+ "name": "getStaticBar",
+ "kind": 6,
+ "range": {
+ "start": {
+ "line": 12,
+ "character": 2
+ },
+ "end": {
+ "line": 12,
+ "character": 57
+ }
+ },
+ "selectionRange": {
+ "start": {
+ "line": 12,
+ "character": 17
+ },
+ "end": {
+ "line": 12,
+ "character": 29
+ }
+ }
+ },
+ {
+ "name": "staticBar",
+ "kind": 7,
+ "range": {
+ "start": {
+ "line": 11,
+ "character": 2
+ },
+ "end": {
+ "line": 11,
+ "character": 32
+ }
+ },
+ "selectionRange": {
+ "start": {
+ "line": 11,
+ "character": 9
+ },
+ "end": {
+ "line": 11,
+ "character": 18
+ }
+ }
+ },
+ {
+ "name": "value",
+ "kind": 7,
+ "range": {
+ "start": {
+ "line": 9,
+ "character": 2
+ },
+ "end": {
+ "line": 9,
+ "character": 35
+ }
+ },
+ "selectionRange": {
+ "start": {
+ "line": 9,
+ "character": 6
+ },
+ "end": {
+ "line": 9,
+ "character": 11
+ }
+ }
+ },
+ {
+ "name": "value",
+ "kind": 7,
+ "range": {
+ "start": {
+ "line": 10,
+ "character": 2
+ },
+ "end": {
+ "line": 10,
+ "character": 42
+ }
+ },
+ "selectionRange": {
+ "start": {
+ "line": 10,
+ "character": 6
+ },
+ "end": {
+ "line": 10,
+ "character": 11
+ }
+ }
+ },
+ {
+ "name": "x",
+ "kind": 7,
+ "range": {
+ "start": {
+ "line": 5,
+ "character": 14
+ },
+ "end": {
+ "line": 5,
+ "character": 30
+ }
+ },
+ "selectionRange": {
+ "start": {
+ "line": 5,
+ "character": 21
+ },
+ "end": {
+ "line": 5,
+ "character": 22
+ }
+ }
+ }
+ ]
+ },
+ {
+ "name": "IFoo",
+ "kind": 11,
+ "range": {
+ "start": {
+ "line": 0,
+ "character": 0
+ },
+ "end": {
+ "line": 2,
+ "character": 1
+ }
+ },
+ "selectionRange": {
+ "start": {
+ "line": 0,
+ "character": 10
+ },
+ "end": {
+ "line": 0,
+ "character": 14
+ }
+ },
+ "children": [
+ {
+ "name": "foo",
+ "kind": 6,
+ "range": {
+ "start": {
+ "line": 1,
+ "character": 2
+ },
+ "end": {
+ "line": 1,
+ "character": 17
+ }
+ },
+ "selectionRange": {
+ "start": {
+ "line": 1,
+ "character": 2
+ },
+ "end": {
+ "line": 1,
+ "character": 5
+ }
+ }
+ }
+ ]
+ },
+ {
+ "name": "Values",
+ "kind": 10,
+ "range": {
+ "start": {
+ "line": 15,
+ "character": 0
+ },
+ "end": {
+ "line": 15,
+ "character": 30
+ }
+ },
+ "selectionRange": {
+ "start": {
+ "line": 15,
+ "character": 5
+ },
+ "end": {
+ "line": 15,
+ "character": 11
+ }
+ },
+ "children": [
+ {
+ "name": "value1",
+ "kind": 13,
+ "range": {
+ "start": {
+ "line": 15,
+ "character": 14
+ },
+ "end": {
+ "line": 15,
+ "character": 20
+ }
+ },
+ "selectionRange": {
+ "start": {
+ "line": 15,
+ "character": 14
+ },
+ "end": {
+ "line": 15,
+ "character": 20
+ }
+ }
+ },
+ {
+ "name": "value2",
+ "kind": 13,
+ "range": {
+ "start": {
+ "line": 15,
+ "character": 22
+ },
+ "end": {
+ "line": 15,
+ "character": 28
+ }
+ },
+ "selectionRange": {
+ "start": {
+ "line": 15,
+ "character": 22
+ },
+ "end": {
+ "line": 15,
+ "character": 28
+ }
+ }
+ }
+ ]
+ }
+]
diff --git a/cli/tests/testdata/lsp/formatting_mbc_response.json b/cli/tests/testdata/lsp/formatting_mbc_response.json
new file mode 100644
index 000000000..1c0b9f8e8
--- /dev/null
+++ b/cli/tests/testdata/lsp/formatting_mbc_response.json
@@ -0,0 +1,54 @@
+[
+ {
+ "range": {
+ "start": {
+ "line": 0,
+ "character": 12
+ },
+ "end": {
+ "line": 0,
+ "character": 13
+ }
+ },
+ "newText": "\""
+ },
+ {
+ "range": {
+ "start": {
+ "line": 0,
+ "character": 21
+ },
+ "end": {
+ "line": 0,
+ "character": 22
+ }
+ },
+ "newText": "\";"
+ },
+ {
+ "range": {
+ "start": {
+ "line": 1,
+ "character": 12
+ },
+ "end": {
+ "line": 1,
+ "character": 13
+ }
+ },
+ "newText": "\""
+ },
+ {
+ "range": {
+ "start": {
+ "line": 1,
+ "character": 23
+ },
+ "end": {
+ "line": 1,
+ "character": 25
+ }
+ },
+ "newText": "\");"
+ }
+]
diff --git a/cli/tests/testdata/lsp/import-map.json b/cli/tests/testdata/lsp/import-map.json
new file mode 100644
index 000000000..75d5d0849
--- /dev/null
+++ b/cli/tests/testdata/lsp/import-map.json
@@ -0,0 +1,5 @@
+{
+ "imports": {
+ "/~/": "./lib/"
+ }
+}
diff --git a/cli/tests/testdata/lsp/incoming_calls_params.json b/cli/tests/testdata/lsp/incoming_calls_params.json
new file mode 100644
index 000000000..6b38d26ee
--- /dev/null
+++ b/cli/tests/testdata/lsp/incoming_calls_params.json
@@ -0,0 +1,28 @@
+{
+ "item": {
+ "name": "baz",
+ "kind": 6,
+ "detail": "Bar",
+ "uri": "file:///a/file.ts",
+ "range": {
+ "start": {
+ "line": 5,
+ "character": 2
+ },
+ "end": {
+ "line": 7,
+ "character": 3
+ }
+ },
+ "selectionRange": {
+ "start": {
+ "line": 5,
+ "character": 2
+ },
+ "end": {
+ "line": 5,
+ "character": 5
+ }
+ }
+ }
+}
diff --git a/cli/tests/testdata/lsp/incoming_calls_response.json b/cli/tests/testdata/lsp/incoming_calls_response.json
new file mode 100644
index 000000000..231919a8c
--- /dev/null
+++ b/cli/tests/testdata/lsp/incoming_calls_response.json
@@ -0,0 +1,42 @@
+[
+ {
+ "from": {
+ "name": "main",
+ "kind": 12,
+ "detail": "",
+ "uri": "file:///a/file.ts",
+ "range": {
+ "start": {
+ "line": 10,
+ "character": 0
+ },
+ "end": {
+ "line": 13,
+ "character": 1
+ }
+ },
+ "selectionRange": {
+ "start": {
+ "line": 10,
+ "character": 9
+ },
+ "end": {
+ "line": 10,
+ "character": 13
+ }
+ }
+ },
+ "fromRanges": [
+ {
+ "start": {
+ "line": 12,
+ "character": 6
+ },
+ "end": {
+ "line": 12,
+ "character": 9
+ }
+ }
+ ]
+ }
+]
diff --git a/cli/tests/testdata/lsp/initialize_params.json b/cli/tests/testdata/lsp/initialize_params.json
new file mode 100644
index 000000000..3b99be4f0
--- /dev/null
+++ b/cli/tests/testdata/lsp/initialize_params.json
@@ -0,0 +1,65 @@
+{
+ "processId": 0,
+ "clientInfo": {
+ "name": "test-harness",
+ "version": "1.0.0"
+ },
+ "rootUri": null,
+ "initializationOptions": {
+ "enable": true,
+ "cache": null,
+ "codeLens": {
+ "implementations": true,
+ "references": true,
+ "test": true
+ },
+ "config": "",
+ "importMap": null,
+ "lint": true,
+ "suggest": {
+ "autoImports": true,
+ "completeFunctionCalls": false,
+ "names": true,
+ "paths": true,
+ "imports": {
+ "hosts": {}
+ }
+ },
+ "unstable": false
+ },
+ "capabilities": {
+ "textDocument": {
+ "codeAction": {
+ "codeActionLiteralSupport": {
+ "codeActionKind": {
+ "valueSet": [
+ "quickfix",
+ "refactor"
+ ]
+ }
+ },
+ "isPreferredSupport": true,
+ "dataSupport": true,
+ "disabledSupport": true,
+ "resolveSupport": {
+ "properties": [
+ "edit"
+ ]
+ }
+ },
+ "foldingRange": {
+ "lineFoldingOnly": true
+ },
+ "synchronization": {
+ "dynamicRegistration": true,
+ "willSave": true,
+ "willSaveWaitUntil": true,
+ "didSave": true
+ }
+ },
+ "workspace": {
+ "configuration": true,
+ "workspaceFolders": true
+ }
+ }
+}
diff --git a/cli/tests/testdata/lsp/initialize_params_bad_config_option.json b/cli/tests/testdata/lsp/initialize_params_bad_config_option.json
new file mode 100644
index 000000000..053cb70f3
--- /dev/null
+++ b/cli/tests/testdata/lsp/initialize_params_bad_config_option.json
@@ -0,0 +1,65 @@
+{
+ "processId": 0,
+ "clientInfo": {
+ "name": "test-harness",
+ "version": "1.0.0"
+ },
+ "rootUri": null,
+ "initializationOptions": {
+ "enable": true,
+ "cache": null,
+ "codeLens": {
+ "implementations": true,
+ "references": true,
+ "test": true
+ },
+ "config": "bad_tsconfig.json",
+ "importMap": null,
+ "lint": true,
+ "suggest": {
+ "autoImports": true,
+ "completeFunctionCalls": false,
+ "names": true,
+ "paths": true,
+ "imports": {
+ "hosts": {}
+ }
+ },
+ "unstable": false
+ },
+ "capabilities": {
+ "textDocument": {
+ "codeAction": {
+ "codeActionLiteralSupport": {
+ "codeActionKind": {
+ "valueSet": [
+ "quickfix",
+ "refactor"
+ ]
+ }
+ },
+ "isPreferredSupport": true,
+ "dataSupport": true,
+ "disabledSupport": true,
+ "resolveSupport": {
+ "properties": [
+ "edit"
+ ]
+ }
+ },
+ "foldingRange": {
+ "lineFoldingOnly": true
+ },
+ "synchronization": {
+ "dynamicRegistration": true,
+ "willSave": true,
+ "willSaveWaitUntil": true,
+ "didSave": true
+ }
+ },
+ "workspace": {
+ "configuration": true,
+ "workspaceFolders": true
+ }
+ }
+}
diff --git a/cli/tests/testdata/lsp/initialize_params_ca_no_disabled.json b/cli/tests/testdata/lsp/initialize_params_ca_no_disabled.json
new file mode 100644
index 000000000..3df87aded
--- /dev/null
+++ b/cli/tests/testdata/lsp/initialize_params_ca_no_disabled.json
@@ -0,0 +1,64 @@
+{
+ "processId": 0,
+ "clientInfo": {
+ "name": "test-harness",
+ "version": "1.0.0"
+ },
+ "rootUri": null,
+ "initializationOptions": {
+ "enable": true,
+ "cache": null,
+ "codeLens": {
+ "implementations": true,
+ "references": true,
+ "test": true
+ },
+ "config": "",
+ "importMap": null,
+ "lint": true,
+ "suggest": {
+ "autoImports": true,
+ "completeFunctionCalls": false,
+ "names": true,
+ "paths": true,
+ "imports": {
+ "hosts": {}
+ }
+ },
+ "unstable": false
+ },
+ "capabilities": {
+ "textDocument": {
+ "codeAction": {
+ "codeActionLiteralSupport": {
+ "codeActionKind": {
+ "valueSet": [
+ "quickfix",
+ "refactor"
+ ]
+ }
+ },
+ "isPreferredSupport": true,
+ "dataSupport": true,
+ "resolveSupport": {
+ "properties": [
+ "edit"
+ ]
+ }
+ },
+ "foldingRange": {
+ "lineFoldingOnly": true
+ },
+ "synchronization": {
+ "dynamicRegistration": true,
+ "willSave": true,
+ "willSaveWaitUntil": true,
+ "didSave": true
+ }
+ },
+ "workspace": {
+ "configuration": true,
+ "workspaceFolders": true
+ }
+ }
+}
diff --git a/cli/tests/testdata/lsp/initialize_params_code_lens_test.json b/cli/tests/testdata/lsp/initialize_params_code_lens_test.json
new file mode 100644
index 000000000..bdd01bfca
--- /dev/null
+++ b/cli/tests/testdata/lsp/initialize_params_code_lens_test.json
@@ -0,0 +1,59 @@
+{
+ "processId": 0,
+ "clientInfo": {
+ "name": "test-harness",
+ "version": "1.0.0"
+ },
+ "rootUri": null,
+ "initializationOptions": {
+ "enable": true,
+ "cache": null,
+ "importMap": null,
+ "lint": true,
+ "suggest": {
+ "autoImports": true,
+ "completeFunctionCalls": false,
+ "names": true,
+ "paths": true,
+ "imports": {
+ "hosts": {}
+ }
+ },
+ "unstable": false
+ },
+ "capabilities": {
+ "textDocument": {
+ "codeAction": {
+ "codeActionLiteralSupport": {
+ "codeActionKind": {
+ "valueSet": [
+ "quickfix",
+ "refactor"
+ ]
+ }
+ },
+ "isPreferredSupport": true,
+ "dataSupport": true,
+ "disabledSupport": true,
+ "resolveSupport": {
+ "properties": [
+ "edit"
+ ]
+ }
+ },
+ "foldingRange": {
+ "lineFoldingOnly": true
+ },
+ "synchronization": {
+ "dynamicRegistration": true,
+ "willSave": true,
+ "willSaveWaitUntil": true,
+ "didSave": true
+ }
+ },
+ "workspace": {
+ "configuration": true,
+ "workspaceFolders": true
+ }
+ }
+}
diff --git a/cli/tests/testdata/lsp/initialize_params_code_lens_test_disabled.json b/cli/tests/testdata/lsp/initialize_params_code_lens_test_disabled.json
new file mode 100644
index 000000000..1d18934ae
--- /dev/null
+++ b/cli/tests/testdata/lsp/initialize_params_code_lens_test_disabled.json
@@ -0,0 +1,64 @@
+{
+ "processId": 0,
+ "clientInfo": {
+ "name": "test-harness",
+ "version": "1.0.0"
+ },
+ "rootUri": null,
+ "initializationOptions": {
+ "enable": true,
+ "cache": null,
+ "codeLens": {
+ "implementations": true,
+ "references": true,
+ "test": false
+ },
+ "importMap": null,
+ "lint": true,
+ "suggest": {
+ "autoImports": true,
+ "completeFunctionCalls": false,
+ "names": true,
+ "paths": true,
+ "imports": {
+ "hosts": {}
+ }
+ },
+ "unstable": false
+ },
+ "capabilities": {
+ "textDocument": {
+ "codeAction": {
+ "codeActionLiteralSupport": {
+ "codeActionKind": {
+ "valueSet": [
+ "quickfix",
+ "refactor"
+ ]
+ }
+ },
+ "isPreferredSupport": true,
+ "dataSupport": true,
+ "disabledSupport": true,
+ "resolveSupport": {
+ "properties": [
+ "edit"
+ ]
+ }
+ },
+ "foldingRange": {
+ "lineFoldingOnly": true
+ },
+ "synchronization": {
+ "dynamicRegistration": true,
+ "willSave": true,
+ "willSaveWaitUntil": true,
+ "didSave": true
+ }
+ },
+ "workspace": {
+ "configuration": true,
+ "workspaceFolders": true
+ }
+ }
+}
diff --git a/cli/tests/testdata/lsp/initialize_params_did_config_change.json b/cli/tests/testdata/lsp/initialize_params_did_config_change.json
new file mode 100644
index 000000000..870ad6e0f
--- /dev/null
+++ b/cli/tests/testdata/lsp/initialize_params_did_config_change.json
@@ -0,0 +1,65 @@
+{
+ "processId": 0,
+ "clientInfo": {
+ "name": "test-harness",
+ "version": "1.0.0"
+ },
+ "rootUri": null,
+ "initializationOptions": {
+ "enable": true,
+ "cache": null,
+ "codeLens": {
+ "implementations": true,
+ "references": true
+ },
+ "importMap": null,
+ "lint": true,
+ "suggest": {
+ "autoImports": true,
+ "completeFunctionCalls": false,
+ "names": true,
+ "paths": true,
+ "imports": {
+ "hosts": {
+ "http://localhost:4545/": false
+ }
+ }
+ },
+ "unstable": false
+ },
+ "capabilities": {
+ "textDocument": {
+ "codeAction": {
+ "codeActionLiteralSupport": {
+ "codeActionKind": {
+ "valueSet": [
+ "quickfix",
+ "refactor"
+ ]
+ }
+ },
+ "isPreferredSupport": true,
+ "dataSupport": true,
+ "disabledSupport": true,
+ "resolveSupport": {
+ "properties": [
+ "edit"
+ ]
+ }
+ },
+ "foldingRange": {
+ "lineFoldingOnly": true
+ },
+ "synchronization": {
+ "dynamicRegistration": true,
+ "willSave": true,
+ "willSaveWaitUntil": true,
+ "didSave": true
+ }
+ },
+ "workspace": {
+ "configuration": true,
+ "workspaceFolders": true
+ }
+ }
+}
diff --git a/cli/tests/testdata/lsp/initialize_params_disabled.json b/cli/tests/testdata/lsp/initialize_params_disabled.json
new file mode 100644
index 000000000..879b1181c
--- /dev/null
+++ b/cli/tests/testdata/lsp/initialize_params_disabled.json
@@ -0,0 +1,63 @@
+{
+ "processId": 0,
+ "clientInfo": {
+ "name": "test-harness",
+ "version": "1.0.0"
+ },
+ "rootUri": null,
+ "initializationOptions": {
+ "enable": false,
+ "cache": null,
+ "codeLens": {
+ "implementations": true,
+ "references": true
+ },
+ "importMap": null,
+ "lint": true,
+ "suggest": {
+ "autoImports": true,
+ "completeFunctionCalls": false,
+ "names": true,
+ "paths": true,
+ "imports": {
+ "hosts": {}
+ }
+ },
+ "unstable": false
+ },
+ "capabilities": {
+ "textDocument": {
+ "codeAction": {
+ "codeActionLiteralSupport": {
+ "codeActionKind": {
+ "valueSet": [
+ "quickfix",
+ "refactor"
+ ]
+ }
+ },
+ "isPreferredSupport": true,
+ "dataSupport": true,
+ "disabledSupport": true,
+ "resolveSupport": {
+ "properties": [
+ "edit"
+ ]
+ }
+ },
+ "foldingRange": {
+ "lineFoldingOnly": true
+ },
+ "synchronization": {
+ "dynamicRegistration": true,
+ "willSave": true,
+ "willSaveWaitUntil": true,
+ "didSave": true
+ }
+ },
+ "workspace": {
+ "configuration": true,
+ "workspaceFolders": true
+ }
+ }
+}
diff --git a/cli/tests/testdata/lsp/initialize_params_registry.json b/cli/tests/testdata/lsp/initialize_params_registry.json
new file mode 100644
index 000000000..67559ebb3
--- /dev/null
+++ b/cli/tests/testdata/lsp/initialize_params_registry.json
@@ -0,0 +1,65 @@
+{
+ "processId": 0,
+ "clientInfo": {
+ "name": "test-harness",
+ "version": "1.0.0"
+ },
+ "rootUri": null,
+ "initializationOptions": {
+ "enable": true,
+ "cache": null,
+ "codeLens": {
+ "implementations": true,
+ "references": true
+ },
+ "importMap": null,
+ "lint": true,
+ "suggest": {
+ "autoImports": true,
+ "completeFunctionCalls": false,
+ "names": true,
+ "paths": true,
+ "imports": {
+ "hosts": {
+ "http://localhost:4545/": true
+ }
+ }
+ },
+ "unstable": false
+ },
+ "capabilities": {
+ "textDocument": {
+ "codeAction": {
+ "codeActionLiteralSupport": {
+ "codeActionKind": {
+ "valueSet": [
+ "quickfix",
+ "refactor"
+ ]
+ }
+ },
+ "isPreferredSupport": true,
+ "dataSupport": true,
+ "disabledSupport": true,
+ "resolveSupport": {
+ "properties": [
+ "edit"
+ ]
+ }
+ },
+ "foldingRange": {
+ "lineFoldingOnly": true
+ },
+ "synchronization": {
+ "dynamicRegistration": true,
+ "willSave": true,
+ "willSaveWaitUntil": true,
+ "didSave": true
+ }
+ },
+ "workspace": {
+ "configuration": true,
+ "workspaceFolders": true
+ }
+ }
+}
diff --git a/cli/tests/testdata/lsp/initialize_params_unstable.json b/cli/tests/testdata/lsp/initialize_params_unstable.json
new file mode 100644
index 000000000..104db16f2
--- /dev/null
+++ b/cli/tests/testdata/lsp/initialize_params_unstable.json
@@ -0,0 +1,63 @@
+{
+ "processId": 0,
+ "clientInfo": {
+ "name": "test-harness",
+ "version": "1.0.0"
+ },
+ "rootUri": null,
+ "initializationOptions": {
+ "enable": true,
+ "cache": null,
+ "codeLens": {
+ "implementations": true,
+ "references": true
+ },
+ "importMap": null,
+ "lint": true,
+ "suggest": {
+ "autoImports": true,
+ "completeFunctionCalls": false,
+ "names": true,
+ "paths": true,
+ "imports": {
+ "hosts": {}
+ }
+ },
+ "unstable": true
+ },
+ "capabilities": {
+ "textDocument": {
+ "codeAction": {
+ "codeActionLiteralSupport": {
+ "codeActionKind": {
+ "valueSet": [
+ "quickfix",
+ "refactor"
+ ]
+ }
+ },
+ "isPreferredSupport": true,
+ "dataSupport": true,
+ "disabledSupport": true,
+ "resolveSupport": {
+ "properties": [
+ "edit"
+ ]
+ }
+ },
+ "foldingRange": {
+ "lineFoldingOnly": true
+ },
+ "synchronization": {
+ "dynamicRegistration": true,
+ "willSave": true,
+ "willSaveWaitUntil": true,
+ "didSave": true
+ }
+ },
+ "workspace": {
+ "configuration": true,
+ "workspaceFolders": true
+ }
+ }
+}
diff --git a/cli/tests/testdata/lsp/lib.tsconfig.json b/cli/tests/testdata/lsp/lib.tsconfig.json
new file mode 100644
index 000000000..8d2ae8a8b
--- /dev/null
+++ b/cli/tests/testdata/lsp/lib.tsconfig.json
@@ -0,0 +1,5 @@
+{
+ "compilerOptions": {
+ "lib": ["deno.ns", "deno.unstable", "dom"]
+ }
+}
diff --git a/cli/tests/testdata/lsp/outgoing_calls_params.json b/cli/tests/testdata/lsp/outgoing_calls_params.json
new file mode 100644
index 000000000..6b38d26ee
--- /dev/null
+++ b/cli/tests/testdata/lsp/outgoing_calls_params.json
@@ -0,0 +1,28 @@
+{
+ "item": {
+ "name": "baz",
+ "kind": 6,
+ "detail": "Bar",
+ "uri": "file:///a/file.ts",
+ "range": {
+ "start": {
+ "line": 5,
+ "character": 2
+ },
+ "end": {
+ "line": 7,
+ "character": 3
+ }
+ },
+ "selectionRange": {
+ "start": {
+ "line": 5,
+ "character": 2
+ },
+ "end": {
+ "line": 5,
+ "character": 5
+ }
+ }
+ }
+}
diff --git a/cli/tests/testdata/lsp/outgoing_calls_response.json b/cli/tests/testdata/lsp/outgoing_calls_response.json
new file mode 100644
index 000000000..c7cf85cf8
--- /dev/null
+++ b/cli/tests/testdata/lsp/outgoing_calls_response.json
@@ -0,0 +1,42 @@
+[
+ {
+ "to": {
+ "name": "foo",
+ "kind": 12,
+ "detail": "",
+ "uri": "file:///a/file.ts",
+ "range": {
+ "start": {
+ "line": 0,
+ "character": 0
+ },
+ "end": {
+ "line": 2,
+ "character": 1
+ }
+ },
+ "selectionRange": {
+ "start": {
+ "line": 0,
+ "character": 9
+ },
+ "end": {
+ "line": 0,
+ "character": 12
+ }
+ }
+ },
+ "fromRanges": [
+ {
+ "start": {
+ "line": 6,
+ "character": 11
+ },
+ "end": {
+ "line": 6,
+ "character": 14
+ }
+ }
+ ]
+ }
+]
diff --git a/cli/tests/testdata/lsp/prepare_call_hierarchy_response.json b/cli/tests/testdata/lsp/prepare_call_hierarchy_response.json
new file mode 100644
index 000000000..93a7d4f1b
--- /dev/null
+++ b/cli/tests/testdata/lsp/prepare_call_hierarchy_response.json
@@ -0,0 +1,28 @@
+[
+ {
+ "name": "baz",
+ "kind": 6,
+ "detail": "Bar",
+ "uri": "file:///a/file.ts",
+ "range": {
+ "start": {
+ "line": 5,
+ "character": 2
+ },
+ "end": {
+ "line": 7,
+ "character": 3
+ }
+ },
+ "selectionRange": {
+ "start": {
+ "line": 5,
+ "character": 2
+ },
+ "end": {
+ "line": 5,
+ "character": 5
+ }
+ }
+ }
+]
diff --git a/cli/tests/testdata/lsp/registries/a_latest.json b/cli/tests/testdata/lsp/registries/a_latest.json
new file mode 100644
index 000000000..f9f9d111e
--- /dev/null
+++ b/cli/tests/testdata/lsp/registries/a_latest.json
@@ -0,0 +1,4 @@
+[
+ "b/c.ts",
+ "d/e.js"
+]
diff --git a/cli/tests/testdata/lsp/registries/a_v1.0.0.json b/cli/tests/testdata/lsp/registries/a_v1.0.0.json
new file mode 100644
index 000000000..f9f9d111e
--- /dev/null
+++ b/cli/tests/testdata/lsp/registries/a_v1.0.0.json
@@ -0,0 +1,4 @@
+[
+ "b/c.ts",
+ "d/e.js"
+]
diff --git a/cli/tests/testdata/lsp/registries/a_v1.0.1.json b/cli/tests/testdata/lsp/registries/a_v1.0.1.json
new file mode 100644
index 000000000..f9f9d111e
--- /dev/null
+++ b/cli/tests/testdata/lsp/registries/a_v1.0.1.json
@@ -0,0 +1,4 @@
+[
+ "b/c.ts",
+ "d/e.js"
+]
diff --git a/cli/tests/testdata/lsp/registries/a_v2.0.0.json b/cli/tests/testdata/lsp/registries/a_v2.0.0.json
new file mode 100644
index 000000000..f9f9d111e
--- /dev/null
+++ b/cli/tests/testdata/lsp/registries/a_v2.0.0.json
@@ -0,0 +1,4 @@
+[
+ "b/c.ts",
+ "d/e.js"
+]
diff --git a/cli/tests/testdata/lsp/registries/a_versions.json b/cli/tests/testdata/lsp/registries/a_versions.json
new file mode 100644
index 000000000..930e38323
--- /dev/null
+++ b/cli/tests/testdata/lsp/registries/a_versions.json
@@ -0,0 +1,5 @@
+[
+ "v1.0.0",
+ "v1.0.1",
+ "v2.0.0"
+]
diff --git a/cli/tests/testdata/lsp/registries/b_latest.json b/cli/tests/testdata/lsp/registries/b_latest.json
new file mode 100644
index 000000000..f9f9d111e
--- /dev/null
+++ b/cli/tests/testdata/lsp/registries/b_latest.json
@@ -0,0 +1,4 @@
+[
+ "b/c.ts",
+ "d/e.js"
+]
diff --git a/cli/tests/testdata/lsp/registries/b_v0.0.1.json b/cli/tests/testdata/lsp/registries/b_v0.0.1.json
new file mode 100644
index 000000000..f9f9d111e
--- /dev/null
+++ b/cli/tests/testdata/lsp/registries/b_v0.0.1.json
@@ -0,0 +1,4 @@
+[
+ "b/c.ts",
+ "d/e.js"
+]
diff --git a/cli/tests/testdata/lsp/registries/b_v0.0.2.json b/cli/tests/testdata/lsp/registries/b_v0.0.2.json
new file mode 100644
index 000000000..f9f9d111e
--- /dev/null
+++ b/cli/tests/testdata/lsp/registries/b_v0.0.2.json
@@ -0,0 +1,4 @@
+[
+ "b/c.ts",
+ "d/e.js"
+]
diff --git a/cli/tests/testdata/lsp/registries/b_v0.0.3.json b/cli/tests/testdata/lsp/registries/b_v0.0.3.json
new file mode 100644
index 000000000..f9f9d111e
--- /dev/null
+++ b/cli/tests/testdata/lsp/registries/b_v0.0.3.json
@@ -0,0 +1,4 @@
+[
+ "b/c.ts",
+ "d/e.js"
+]
diff --git a/cli/tests/testdata/lsp/registries/b_versions.json b/cli/tests/testdata/lsp/registries/b_versions.json
new file mode 100644
index 000000000..9532fbb85
--- /dev/null
+++ b/cli/tests/testdata/lsp/registries/b_versions.json
@@ -0,0 +1,5 @@
+[
+ "v0.0.1",
+ "v0.0.2",
+ "v0.0.3"
+]
diff --git a/cli/tests/testdata/lsp/registries/deno-import-intellisense.json b/cli/tests/testdata/lsp/registries/deno-import-intellisense.json
new file mode 100644
index 000000000..8aa4a4eca
--- /dev/null
+++ b/cli/tests/testdata/lsp/registries/deno-import-intellisense.json
@@ -0,0 +1,35 @@
+{
+ "version": 1,
+ "registries": [
+ {
+ "schema": "/x/:module([a-z0-9_]*)@:version?/:path*",
+ "variables": [
+ {
+ "key": "module",
+ "url": "http://localhost:4545/lsp/registries/modules.json"
+ },
+ {
+ "key": "version",
+ "url": "http://localhost:4545/lsp/registries/${module}_versions.json"
+ },
+ {
+ "key": "path",
+ "url": "http://localhost:4545/lsp/registries/${module}_${{version}}.json"
+ }
+ ]
+ },
+ {
+ "schema": "/x/:module([a-z0-9_]*)/:path*",
+ "variables": [
+ {
+ "key": "module",
+ "url": "http://localhost:4545/lsp/registries/modules.json"
+ },
+ {
+ "key": "path",
+ "url": "http://localhost:4545/lsp/registries/${module}_latest.json"
+ }
+ ]
+ }
+ ]
+}
diff --git a/cli/tests/testdata/lsp/registries/modules.json b/cli/tests/testdata/lsp/registries/modules.json
new file mode 100644
index 000000000..517c9d68e
--- /dev/null
+++ b/cli/tests/testdata/lsp/registries/modules.json
@@ -0,0 +1,4 @@
+[
+ "a",
+ "b"
+]
diff --git a/cli/tests/testdata/lsp/rename_response.json b/cli/tests/testdata/lsp/rename_response.json
new file mode 100644
index 000000000..5e0e28e4c
--- /dev/null
+++ b/cli/tests/testdata/lsp/rename_response.json
@@ -0,0 +1,38 @@
+{
+ "documentChanges": [
+ {
+ "textDocument": {
+ "uri": "file:///a/file.ts",
+ "version": 1
+ },
+ "edits": [
+ {
+ "range": {
+ "start": {
+ "line": 0,
+ "character": 4
+ },
+ "end": {
+ "line": 0,
+ "character": 12
+ }
+ },
+ "newText": "variable_modified"
+ },
+ {
+ "range": {
+ "start": {
+ "line": 1,
+ "character": 12
+ },
+ "end": {
+ "line": 1,
+ "character": 20
+ }
+ },
+ "newText": "variable_modified"
+ }
+ ]
+ }
+ ]
+}
diff --git a/cli/tests/testdata/lsp/selection_range_response.json b/cli/tests/testdata/lsp/selection_range_response.json
new file mode 100644
index 000000000..b5eef5ddc
--- /dev/null
+++ b/cli/tests/testdata/lsp/selection_range_response.json
@@ -0,0 +1,86 @@
+[
+ {
+ "range": {
+ "start": {
+ "line": 2,
+ "character": 8
+ },
+ "end": {
+ "line": 2,
+ "character": 9
+ }
+ },
+ "parent": {
+ "range": {
+ "start": {
+ "line": 2,
+ "character": 8
+ },
+ "end": {
+ "line": 2,
+ "character": 15
+ }
+ },
+ "parent": {
+ "range": {
+ "start": {
+ "line": 2,
+ "character": 4
+ },
+ "end": {
+ "line": 4,
+ "character": 5
+ }
+ },
+ "parent": {
+ "range": {
+ "start": {
+ "line": 1,
+ "character": 13
+ },
+ "end": {
+ "line": 6,
+ "character": 2
+ }
+ },
+ "parent": {
+ "range": {
+ "start": {
+ "line": 1,
+ "character": 2
+ },
+ "end": {
+ "line": 6,
+ "character": 3
+ }
+ },
+ "parent": {
+ "range": {
+ "start": {
+ "line": 0,
+ "character": 11
+ },
+ "end": {
+ "line": 7,
+ "character": 0
+ }
+ },
+ "parent": {
+ "range": {
+ "start": {
+ "line": 0,
+ "character": 0
+ },
+ "end": {
+ "line": 7,
+ "character": 1
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+]
diff --git a/cli/tests/testdata/lsp/types.tsconfig.json b/cli/tests/testdata/lsp/types.tsconfig.json
new file mode 100644
index 000000000..ba7f3344d
--- /dev/null
+++ b/cli/tests/testdata/lsp/types.tsconfig.json
@@ -0,0 +1,7 @@
+{
+ "compilerOptions": {
+ "types": [
+ "./a.d.ts"
+ ]
+ }
+}