diff options
| author | David Sherret <dsherret@users.noreply.github.com> | 2023-03-08 18:15:20 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-08 23:15:20 +0000 |
| commit | 25d98ca289af64f85759fe10c8808afbfb7011e3 (patch) | |
| tree | 79f0126791ae317b030696b7c507dee6420a660e /cli/tests/testdata | |
| parent | f2e5e01832a40eb71be82f1b46304c56aa2e8dba (diff) | |
refactor(lsp): improve test client initialization (#18015)
Diffstat (limited to 'cli/tests/testdata')
82 files changed, 676 insertions, 4130 deletions
diff --git a/cli/tests/testdata/lsp/a.d.ts b/cli/tests/testdata/lsp/a.d.ts deleted file mode 100644 index 536a6d0a6..000000000 --- a/cli/tests/testdata/lsp/a.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -// deno-lint-ignore-file no-var -declare var a: string; diff --git a/cli/tests/testdata/lsp/b.d.ts b/cli/tests/testdata/lsp/b.d.ts deleted file mode 100644 index 2fd56623b..000000000 --- a/cli/tests/testdata/lsp/b.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -// deno-lint-ignore-file no-var -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 deleted file mode 100644 index 7711812fd..000000000 --- a/cli/tests/testdata/lsp/code_action_ignore_lint_params.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "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 deleted file mode 100644 index d15fccca9..000000000 --- a/cli/tests/testdata/lsp/code_action_ignore_lint_response.json +++ /dev/null @@ -1,92 +0,0 @@ -[ - { - "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": "Disable prefer-const 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 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 deleted file mode 100644 index d026d61f6..000000000 --- a/cli/tests/testdata/lsp/code_action_params.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "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 deleted file mode 100644 index 61ae555a3..000000000 --- a/cli/tests/testdata/lsp/code_action_params_cache.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "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 deleted file mode 100644 index be0e317e1..000000000 --- a/cli/tests/testdata/lsp/code_action_params_deadlock.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "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_import_assertion.json b/cli/tests/testdata/lsp/code_action_params_import_assertion.json deleted file mode 100644 index 67b822a42..000000000 --- a/cli/tests/testdata/lsp/code_action_params_import_assertion.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "textDocument": { - "uri": "file:///a/a.ts" - }, - "range": { - "start": { - "line": 0, - "character": 14 - }, - "end": { - "line": 0, - "character": 27 - } - }, - "context": { - "diagnostics": [ - { - "range": { - "start": { - "line": 0, - "character": 14 - }, - "end": { - "line": 0, - "character": 27 - } - }, - "severity": 1, - "code": "no-assert-type", - "source": "deno", - "message": "The module is a JSON module and not being imported with an import assertion. Consider adding `assert { type: \"json\" }` to the import statement." - } - ], - "only": [ - "quickfix" - ] - } -} diff --git a/cli/tests/testdata/lsp/code_action_params_imports.json b/cli/tests/testdata/lsp/code_action_params_imports.json deleted file mode 100644 index 891257ca0..000000000 --- a/cli/tests/testdata/lsp/code_action_params_imports.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "textDocument": { - "uri": "file:///a/file00.ts" - }, - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 6, - "character": 0 - } - }, - "context": { - "diagnostics": [ - { - "range": { - "start": { - "line": 0, - "character": 50 - }, - "end": { - "line": 0, - "character": 67 - } - }, - "severity": 1, - "code": 2304, - "source": "deno-ts", - "message": "Cannot find name 'DuckConfigOptions'." - }, - { - "range": { - "start": { - "line": 4, - "character": 39 - }, - "end": { - "line": 4, - "character": 49 - } - }, - "severity": 1, - "code": 2304, - "source": "deno-ts", - "message": "Cannot find name 'DuckConfig'." - } - ], - "only": [ - "quickfix" - ] - } -} diff --git a/cli/tests/testdata/lsp/code_action_params_refactor.json b/cli/tests/testdata/lsp/code_action_params_refactor.json deleted file mode 100644 index 121c400ed..000000000 --- a/cli/tests/testdata/lsp/code_action_params_refactor.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "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_redirect_response.json b/cli/tests/testdata/lsp/code_action_redirect_response.json deleted file mode 100644 index 235127570..000000000 --- a/cli/tests/testdata/lsp/code_action_redirect_response.json +++ /dev/null @@ -1,47 +0,0 @@ -[ - { - "title": "Update specifier to its redirected specifier.", - "kind": "quickfix", - "diagnostics": [ - { - "range": { - "start": { - "line": 0, - "character": 19 - }, - "end": { - "line": 0, - "character": 60 - } - }, - "severity": 3, - "code": "redirect", - "source": "deno", - "message": "The import of \"http://127.0.0.1:4545/x_deno_warning.js\" was redirected to \"http://127.0.0.1:4545/lsp/x_deno_warning_redirect.js\".", - "data": { - "specifier": "http://127.0.0.1:4545/x_deno_warning.js", - "redirect": "http://127.0.0.1:4545/lsp/x_deno_warning_redirect.js" - } - } - ], - "edit": { - "changes": { - "file:///a/file.ts": [ - { - "range": { - "start": { - "line": 0, - "character": 19 - }, - "end": { - "line": 0, - "character": 60 - } - }, - "newText": "\"http://127.0.0.1:4545/lsp/x_deno_warning_redirect.js\"" - } - ] - } - } - } -] diff --git a/cli/tests/testdata/lsp/code_action_resolve_params.json b/cli/tests/testdata/lsp/code_action_resolve_params.json deleted file mode 100644 index 50c1f9a43..000000000 --- a/cli/tests/testdata/lsp/code_action_resolve_params.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "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 deleted file mode 100644 index 5e1beb87b..000000000 --- a/cli/tests/testdata/lsp/code_action_resolve_params_imports.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "title": "Add all missing imports", - "kind": "quickfix", - "diagnostics": [ - { - "range": { - "start": { - "line": 0, - "character": 50 - }, - "end": { - "line": 0, - "character": 67 - } - }, - "severity": 1, - "code": 2304, - "source": "deno-ts", - "message": "Cannot find name 'DuckConfigOptions'." - }, - { - "range": { - "start": { - "line": 4, - "character": 39 - }, - "end": { - "line": 4, - "character": 49 - } - }, - "severity": 1, - "code": 2304, - "source": "deno-ts", - "message": "Cannot find name 'DuckConfig'." - } - ], - "data": { - "specifier": "file:///a/file00.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 deleted file mode 100644 index d4bb3bd81..000000000 --- a/cli/tests/testdata/lsp/code_action_resolve_params_refactor.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "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 deleted file mode 100644 index e3f5b3f0e..000000000 --- a/cli/tests/testdata/lsp/code_action_resolve_response.json +++ /dev/null @@ -1,91 +0,0 @@ -{ - "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 deleted file mode 100644 index 6ffc3192e..000000000 --- a/cli/tests/testdata/lsp/code_action_resolve_response_imports.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "title": "Add all missing imports", - "kind": "quickfix", - "diagnostics": [ - { - "range": { - "start": { - "line": 0, - "character": 50 - }, - "end": { - "line": 0, - "character": 67 - } - }, - "severity": 1, - "code": 2304, - "source": "deno-ts", - "message": "Cannot find name 'DuckConfigOptions'." - }, - { - "range": { - "start": { - "line": 4, - "character": 39 - }, - "end": { - "line": 4, - "character": 49 - } - }, - "severity": 1, - "code": 2304, - "source": "deno-ts", - "message": "Cannot find name 'DuckConfig'." - } - ], - "edit": { - "documentChanges": [ - { - "textDocument": { - "uri": "file:///a/file00.ts", - "version": 1 - }, - "edits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import { DuckConfig } from \"./file01.ts\";\nimport { DuckConfigOptions } from \"./file02.ts\";\n\n" - } - ] - } - ] - }, - "data": { - "specifier": "file:///a/file00.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 deleted file mode 100644 index 721a76a6b..000000000 --- a/cli/tests/testdata/lsp/code_action_resolve_response_refactor.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "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 deleted file mode 100644 index ab30898f8..000000000 --- a/cli/tests/testdata/lsp/code_action_response.json +++ /dev/null @@ -1,90 +0,0 @@ -[ - { - "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 deleted file mode 100644 index c56b35023..000000000 --- a/cli/tests/testdata/lsp/code_action_response_cache.json +++ /dev/null @@ -1,36 +0,0 @@ -[ - { - "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_import_assertion.json b/cli/tests/testdata/lsp/code_action_response_import_assertion.json deleted file mode 100644 index bff934b21..000000000 --- a/cli/tests/testdata/lsp/code_action_response_import_assertion.json +++ /dev/null @@ -1,43 +0,0 @@ -[ - { - "title": "Insert import assertion.", - "kind": "quickfix", - "diagnostics": [ - { - "range": { - "start": { - "line": 0, - "character": 14 - }, - "end": { - "line": 0, - "character": 27 - } - }, - "severity": 1, - "code": "no-assert-type", - "source": "deno", - "message": "The module is a JSON module and not being imported with an import assertion. Consider adding `assert { type: \"json\" }` to the import statement." - } - ], - "edit": { - "changes": { - "file:///a/a.ts": [ - { - "range": { - "start": { - "line": 0, - "character": 27 - }, - "end": { - "line": 0, - "character": 27 - } - }, - "newText": " assert { type: \"json\" }" - } - ] - } - } - } -] diff --git a/cli/tests/testdata/lsp/code_action_response_imports.json b/cli/tests/testdata/lsp/code_action_response_imports.json deleted file mode 100644 index 23eb6645d..000000000 --- a/cli/tests/testdata/lsp/code_action_response_imports.json +++ /dev/null @@ -1,122 +0,0 @@ -[ - { - "title": "Add import from \"./file02.ts\"", - "kind": "quickfix", - "diagnostics": [ - { - "range": { - "start": { - "line": 0, - "character": 50 - }, - "end": { - "line": 0, - "character": 67 - } - }, - "severity": 1, - "code": 2304, - "source": "deno-ts", - "message": "Cannot find name 'DuckConfigOptions'." - } - ], - "edit": { - "documentChanges": [ - { - "textDocument": { - "uri": "file:///a/file00.ts", - "version": 1 - }, - "edits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import { DuckConfigOptions } from \"./file02.ts\";\n\n" - } - ] - } - ] - } - }, - { - "title": "Add all missing imports", - "kind": "quickfix", - "diagnostics": [ - { - "range": { - "start": { - "line": 0, - "character": 50 - }, - "end": { - "line": 0, - "character": 67 - } - }, - "severity": 1, - "code": 2304, - "source": "deno-ts", - "message": "Cannot find name 'DuckConfigOptions'." - } - ], - "data": { - "specifier": "file:///a/file00.ts", - "fixId": "fixMissingImport" - } - }, - { - "title": "Add import from \"./file01.ts\"", - "kind": "quickfix", - "diagnostics": [ - { - "range": { - "start": { - "line": 4, - "character": 39 - }, - "end": { - "line": 4, - "character": 49 - } - }, - "severity": 1, - "code": 2304, - "source": "deno-ts", - "message": "Cannot find name 'DuckConfig'." - } - ], - "edit": { - "documentChanges": [ - { - "textDocument": { - "uri": "file:///a/file00.ts", - "version": 1 - }, - "edits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import { DuckConfig } from \"./file01.ts\";\n\n" - } - ] - } - ] - } - } -] diff --git a/cli/tests/testdata/lsp/code_action_response_no_disabled.json b/cli/tests/testdata/lsp/code_action_response_no_disabled.json deleted file mode 100644 index 11d2136b5..000000000 --- a/cli/tests/testdata/lsp/code_action_response_no_disabled.json +++ /dev/null @@ -1,42 +0,0 @@ -[ - { - "title": "Extract to function in module scope", - "kind": "refactor.extract.function", - "isPreferred": false, - "data": { - "specifier": "file:///a/file.ts", - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 14, - "character": 0 - } - }, - "refactorName": "Extract Symbol", - "actionName": "function_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": 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 deleted file mode 100644 index d0d9fb0ee..000000000 --- a/cli/tests/testdata/lsp/code_action_response_refactor.json +++ /dev/null @@ -1,177 +0,0 @@ -[ - { - "title": "Extract to function in module 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 default import", - "kind": "refactor.rewrite.import.default", - "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 default import" - } - }, - { - "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" - } - } -] diff --git a/cli/tests/testdata/lsp/code_action_update_ignore_lint_params.json b/cli/tests/testdata/lsp/code_action_update_ignore_lint_params.json deleted file mode 100644 index 8cbf1185f..000000000 --- a/cli/tests/testdata/lsp/code_action_update_ignore_lint_params.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "textDocument": { - "uri": "file:///a/file.ts" - }, - "range": { - "start": { - "line": 3, - "character": 5 - }, - "end": { - "line": 3, - "character": 15 - } - }, - "context": { - "diagnostics": [ - { - "range": { - "start": { - "line": 3, - "character": 5 - }, - "end": { - "line": 3, - "character": 15 - } - }, - "severity": 1, - "code": "prefer-const", - "source": "deno-lint", - "message": "'snake_case' is never reassigned\nUse 'const' instead", - "relatedInformation": [] - } - ], - "only": [ - "quickfix" - ] - } -} diff --git a/cli/tests/testdata/lsp/code_action_update_ignore_lint_response.json b/cli/tests/testdata/lsp/code_action_update_ignore_lint_response.json deleted file mode 100644 index a23e719e0..000000000 --- a/cli/tests/testdata/lsp/code_action_update_ignore_lint_response.json +++ /dev/null @@ -1,92 +0,0 @@ -[ - { - "title": "Disable prefer-const for this line", - "kind": "quickfix", - "diagnostics": [ - { - "range": { - "start": { "line": 3, "character": 5 }, - "end": { "line": 3, "character": 15 } - }, - "severity": 1, - "code": "prefer-const", - "source": "deno-lint", - "message": "'snake_case' is never reassigned\nUse 'const' instead", - "relatedInformation": [] - } - ], - "edit": { - "changes": { - "file:///a/file.ts": [ - { - "range": { - "start": { "line": 3, "character": 0 }, - "end": { "line": 3, "character": 0 } - }, - "newText": "// deno-lint-ignore prefer-const\n" - } - ] - } - } - }, - { - "title": "Disable prefer-const for the entire file", - "kind": "quickfix", - "diagnostics": [ - { - "range": { - "start": { "line": 3, "character": 5 }, - "end": { "line": 3, "character": 15 } - }, - "severity": 1, - "code": "prefer-const", - "source": "deno-lint", - "message": "'snake_case' is never reassigned\nUse 'const' instead", - "relatedInformation": [] - } - ], - "edit": { - "changes": { - "file:///a/file.ts": [ - { - "range": { - "start": { "line": 1, "character": 34 }, - "end": { "line": 1, "character": 34 } - }, - "newText": " prefer-const" - } - ] - } - } - }, - { - "title": "Ignore lint errors for the entire file", - "kind": "quickfix", - "diagnostics": [ - { - "range": { - "start": { "line": 3, "character": 5 }, - "end": { "line": 3, "character": 15 } - }, - "severity": 1, - "code": "prefer-const", - "source": "deno-lint", - "message": "'snake_case' 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_actions/cache_npm/cache_action.json b/cli/tests/testdata/lsp/code_actions/cache_npm/cache_action.json deleted file mode 100644 index b698df3bd..000000000 --- a/cli/tests/testdata/lsp/code_actions/cache_npm/cache_action.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "textDocument": { - "uri": "file:///a/file.ts" - }, - "range": { - "start": { - "line": 0, - "character": 18 - }, - "end": { - "line": 0, - "character": 29 - } - }, - "context": { - "diagnostics": [ - { - "range": { - "start": { - "line": 0, - "character": 18 - }, - "end": { - "line": 0, - "character": 29 - } - }, - "severity": 1, - "code": "no-cache-npm", - "source": "deno", - "message": "Uncached or missing npm package: \"chalk\".", - "data": { - "specifier": "npm:chalk" - } - } - ], - "only": [ - "quickfix" - ] - } -} diff --git a/cli/tests/testdata/lsp/code_actions/cache_npm/cache_response.json b/cli/tests/testdata/lsp/code_actions/cache_npm/cache_response.json deleted file mode 100644 index 1b41babcb..000000000 --- a/cli/tests/testdata/lsp/code_actions/cache_npm/cache_response.json +++ /dev/null @@ -1,36 +0,0 @@ -[ - { - "title": "Cache \"npm:chalk\" and its dependencies.", - "kind": "quickfix", - "diagnostics": [ - { - "range": { - "start": { - "line": 0, - "character": 18 - }, - "end": { - "line": 0, - "character": 29 - } - }, - "severity": 1, - "code": "no-cache-npm", - "source": "deno", - "message": "Uncached or missing npm package: \"chalk\".", - "data": { - "specifier": "npm:chalk" - } - } - ], - "command": { - "title": "", - "command": "deno.cache", - "arguments": [ - [ - "npm:chalk" - ] - ] - } - } -] diff --git a/cli/tests/testdata/lsp/code_actions/cache_npm/diagnostics.json b/cli/tests/testdata/lsp/code_actions/cache_npm/diagnostics.json deleted file mode 100644 index 63c9d0029..000000000 --- a/cli/tests/testdata/lsp/code_actions/cache_npm/diagnostics.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "uri": "file:///a/file.ts", - "diagnostics": [ - { - "range": { - "start": { - "line": 0, - "character": 18 - }, - "end": { - "line": 0, - "character": 29 - } - }, - "severity": 1, - "code": "no-cache-npm", - "source": "deno", - "message": "Uncached or missing npm package: \"chalk\".", - "data": { - "specifier": "npm:chalk" - } - } - ], - "version": 1 -} diff --git a/cli/tests/testdata/lsp/code_lens_resolve_response.json b/cli/tests/testdata/lsp/code_lens_resolve_response.json deleted file mode 100644 index a958b4db4..000000000 --- a/cli/tests/testdata/lsp/code_lens_resolve_response.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "range": { - "start": { - "line": 0, - "character": 6 - }, - "end": { - "line": 0, - "character": 7 - } - }, - "command": { - "title": "2 references", - "command": "deno.showReferences", - "arguments": [ - "file:///a/file.ts", - { - "line": 0, - "character": 6 - }, - [ - { - "uri": "file:///a/file.ts", - "range": { - "start": { - "line": 0, - "character": 6 - }, - "end": { - "line": 0, - "character": 7 - } - } - }, - { - "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 deleted file mode 100644 index cabf2f833..000000000 --- a/cli/tests/testdata/lsp/code_lens_resolve_response_impl.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "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 deleted file mode 100644 index e3a87e4be..000000000 --- a/cli/tests/testdata/lsp/code_lens_response.json +++ /dev/null @@ -1,34 +0,0 @@ -[ - { - "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 deleted file mode 100644 index b0073a23f..000000000 --- a/cli/tests/testdata/lsp/code_lens_response_changed.json +++ /dev/null @@ -1,50 +0,0 @@ -[ - { - "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 deleted file mode 100644 index c6e5bd92d..000000000 --- a/cli/tests/testdata/lsp/code_lens_response_impl.json +++ /dev/null @@ -1,98 +0,0 @@ -[ - { - "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 deleted file mode 100644 index 159839816..000000000 --- a/cli/tests/testdata/lsp/code_lens_response_test.json +++ /dev/null @@ -1,370 +0,0 @@ -[ - { - "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", - { - "inspect": false - } - ] - } - }, - { - "range": { - "start": { - "line": 4, - "character": 5 - }, - "end": { - "line": 4, - "character": 9 - } - }, - "command": { - "title": "Debug", - "command": "deno.test", - "arguments": [ - "file:///a/file.ts", - "test a", - { - "inspect": true - } - ] - } - }, - { - "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", - { - "inspect": false - } - ] - } - }, - { - "range": { - "start": { - "line": 5, - "character": 5 - }, - "end": { - "line": 5, - "character": 9 - } - }, - "command": { - "title": "Debug", - "command": "deno.test", - "arguments": [ - "file:///a/file.ts", - "test b", - { - "inspect": true - } - ] - } - }, - { - "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", - { - "inspect": false - } - ] - } - }, - { - "range": { - "start": { - "line": 9, - "character": 0 - }, - "end": { - "line": 9, - "character": 4 - } - }, - "command": { - "title": "Debug", - "command": "deno.test", - "arguments": [ - "file:///a/file.ts", - "test c", - { - "inspect": true - } - ] - } - }, - { - "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", - { - "inspect": false - } - ] - } - }, - { - "range": { - "start": { - "line": 13, - "character": 0 - }, - "end": { - "line": 13, - "character": 4 - } - }, - "command": { - "title": "Debug", - "command": "deno.test", - "arguments": [ - "file:///a/file.ts", - "test d", - { - "inspect": true - } - ] - } - }, - { - "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", - { - "inspect": false - } - ] - } - }, - { - "range": { - "start": { - "line": 14, - "character": 0 - }, - "end": { - "line": 14, - "character": 5 - } - }, - "command": { - "title": "Debug", - "command": "deno.test", - "arguments": [ - "file:///a/file.ts", - "test e", - { - "inspect": true - } - ] - } - }, - { - "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", - { - "inspect": false - } - ] - } - }, - { - "range": { - "start": { - "line": 18, - "character": 0 - }, - "end": { - "line": 18, - "character": 5 - } - }, - "command": { - "title": "Debug", - "command": "deno.test", - "arguments": [ - "file:///a/file.ts", - "test f", - { - "inspect": true - } - ] - } - }, - { - "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", - { - "inspect": false - } - ] - } - }, - { - "range": { - "start": { - "line": 19, - "character": 0 - }, - "end": { - "line": 19, - "character": 5 - } - }, - "command": { - "title": "Debug", - "command": "deno.test", - "arguments": [ - "file:///a/file.ts", - "test g", - { - "inspect": true - } - ] - } - }, - { - "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", - { - "inspect": false - } - ] - } - }, - { - "range": { - "start": { - "line": 23, - "character": 0 - }, - "end": { - "line": 23, - "character": 5 - } - }, - "command": { - "title": "Debug", - "command": "deno.test", - "arguments": [ - "file:///a/file.ts", - "test h", - { - "inspect": true - } - ] - } - } -] diff --git a/cli/tests/testdata/lsp/completion_request_params_optional.json b/cli/tests/testdata/lsp/completion_request_params_optional.json deleted file mode 100644 index 1f3c079c7..000000000 --- a/cli/tests/testdata/lsp/completion_request_params_optional.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "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 deleted file mode 100644 index 9ece16e90..000000000 --- a/cli/tests/testdata/lsp/completion_request_response_empty.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "isIncomplete": false, - "items": [ - { - "label": ".", - "kind": 19, - "detail": "(local)", - "sortText": "1", - "insertText": ".", - "commitCharacters": [ - "\"", - "'" - ] - }, - { - "label": "..", - "kind": 19, - "detail": "(local)", - "sortText": "1", - "insertText": "..", - "commitCharacters": [ - "\"", - "'" - ] - }, - { - "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" - }, - "commitCharacters": [ - "\"", - "'", - "/" - ] - } - ] -} diff --git a/cli/tests/testdata/lsp/completion_resolve_params.json b/cli/tests/testdata/lsp/completion_resolve_params.json deleted file mode 100644 index 26231036d..000000000 --- a/cli/tests/testdata/lsp/completion_resolve_params.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "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 deleted file mode 100644 index cb99bf960..000000000 --- a/cli/tests/testdata/lsp/completion_resolve_params_optional.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "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 deleted file mode 100644 index 99a4a048e..000000000 --- a/cli/tests/testdata/lsp/completion_resolve_params_registry.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "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 deleted file mode 100644 index 28ad756a3..000000000 --- a/cli/tests/testdata/lsp/completion_resolve_response.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "label": "build", - "kind": 6, - "detail": "const Deno.build: {\n target: string;\n arch: \"x86_64\" | \"aarch64\";\n os: \"darwin\" | \"linux\" | \"windows\" | \"freebsd\" | \"netbsd\" | \"aix\" | \"solaris\" | \"illumos\";\n vendor: string;\n env?: string | undefined;\n}", - "documentation": { - "kind": "markdown", - "value": "Information related to the build of the current Deno runtime.\n\nUsers are discouraged from code branching based on this information, as\nassumptions about what is available in what build environment might change\nover time. Developers should specifically sniff out the features they\nintend to use.\n\nThe intended use for the information is for logging and debugging purposes.\n\n*@category* - Runtime Environment" - }, - "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 deleted file mode 100644 index 99a4a048e..000000000 --- a/cli/tests/testdata/lsp/completion_resolve_response_registry.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "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/completions/npm/resolve_params.json b/cli/tests/testdata/lsp/completions/npm/resolve_params.json deleted file mode 100644 index c83b8ce49..000000000 --- a/cli/tests/testdata/lsp/completions/npm/resolve_params.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "label": "MyClass", - "kind": 6, - "sortText": "1", - "insertTextFormat": 1, - "data": { - "tsc": { - "specifier": "file:///a/file.ts", - "position": 69, - "name": "MyClass", - "useCodeSnippet": false - } - } -} diff --git a/cli/tests/testdata/lsp/completions/npm/resolve_response.json b/cli/tests/testdata/lsp/completions/npm/resolve_response.json deleted file mode 100644 index c83b8ce49..000000000 --- a/cli/tests/testdata/lsp/completions/npm/resolve_response.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "label": "MyClass", - "kind": 6, - "sortText": "1", - "insertTextFormat": 1, - "data": { - "tsc": { - "specifier": "file:///a/file.ts", - "position": 69, - "name": "MyClass", - "useCodeSnippet": false - } - } -} diff --git a/cli/tests/testdata/lsp/deno.embedded_import_map.jsonc b/cli/tests/testdata/lsp/deno.embedded_import_map.jsonc deleted file mode 100644 index 75d5d0849..000000000 --- a/cli/tests/testdata/lsp/deno.embedded_import_map.jsonc +++ /dev/null @@ -1,5 +0,0 @@ -{ - "imports": { - "/~/": "./lib/" - } -} diff --git a/cli/tests/testdata/lsp/deno.fmt.exclude.jsonc b/cli/tests/testdata/lsp/deno.fmt.exclude.jsonc deleted file mode 100644 index 246a40316..000000000 --- a/cli/tests/testdata/lsp/deno.fmt.exclude.jsonc +++ /dev/null @@ -1,16 +0,0 @@ -{ - "fmt": { - "files": { - "exclude": [ - "ignored.ts" - ] - }, - "options": { - "useTabs": true, - "lineWidth": 40, - "indentWidth": 8, - "singleQuote": true, - "proseWrap": "always" - } - } -} diff --git a/cli/tests/testdata/lsp/deno.fmt.jsonc b/cli/tests/testdata/lsp/deno.fmt.jsonc deleted file mode 100644 index a0a851731..000000000 --- a/cli/tests/testdata/lsp/deno.fmt.jsonc +++ /dev/null @@ -1,11 +0,0 @@ -{ - "fmt": { - "options": { - "useTabs": true, - "lineWidth": 40, - "indentWidth": 8, - "singleQuote": true, - "proseWrap": "always" - } - } -} diff --git a/cli/tests/testdata/lsp/deno.lint.jsonc b/cli/tests/testdata/lsp/deno.lint.jsonc deleted file mode 100644 index 03308ab5f..000000000 --- a/cli/tests/testdata/lsp/deno.lint.jsonc +++ /dev/null @@ -1,13 +0,0 @@ -{ - "lint": { - "rules": { - "exclude": [ - "camelcase" - ], - "include": [ - "ban-untagged-todo" - ], - "tags": [] - } - } -} diff --git a/cli/tests/testdata/lsp/diagnostics_deno_deps.json b/cli/tests/testdata/lsp/diagnostics_deno_deps.json deleted file mode 100644 index ec6cc4f51..000000000 --- a/cli/tests/testdata/lsp/diagnostics_deno_deps.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "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/did_open_lint.json b/cli/tests/testdata/lsp/did_open_lint.json deleted file mode 100644 index 51cef9807..000000000 --- a/cli/tests/testdata/lsp/did_open_lint.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "textDocument": { - "uri": "file:///a/file.ts", - "languageId": "typescript", - "version": 1, - "text": "// TODO: fixme\nexport async function non_camel_case() {\nconsole.log(\"finished!\")\n}" - } -} diff --git a/cli/tests/testdata/lsp/did_open_params_deno_types.json b/cli/tests/testdata/lsp/did_open_params_deno_types.json deleted file mode 100644 index 6f085d045..000000000 --- a/cli/tests/testdata/lsp/did_open_params_deno_types.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "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 deleted file mode 100644 index c74877191..000000000 --- a/cli/tests/testdata/lsp/did_open_params_doc_symbol.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "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 deleted file mode 100644 index a79ba0d7f..000000000 --- a/cli/tests/testdata/lsp/did_open_params_import_hover.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "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\";\nimport * as g from \"http://localhost:4545/x/a/mod.ts\";\n\nconsole.log(a, b, c, d, e, f, g);\n" - } -} diff --git a/cli/tests/testdata/lsp/did_open_params_large.json b/cli/tests/testdata/lsp/did_open_params_large.json deleted file mode 100644 index 0347ab67b..000000000 --- a/cli/tests/testdata/lsp/did_open_params_large.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "textDocument": { - "uri": "file:///a/file.ts", - "languageId": "javascript", - "version": 1, - "text": "// Copyright 2018-2023 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 deleted file mode 100644 index 5cf48ae05..000000000 --- a/cli/tests/testdata/lsp/did_open_params_semantic_tokens.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "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 deleted file mode 100644 index dcb9e11f3..000000000 --- a/cli/tests/testdata/lsp/did_open_params_test_code_lens.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "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/did_open_params_tls_cert.json b/cli/tests/testdata/lsp/did_open_params_tls_cert.json deleted file mode 100644 index 2942bfcbe..000000000 --- a/cli/tests/testdata/lsp/did_open_params_tls_cert.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "textDocument": { - "uri": "file:///a/file.ts", - "languageId": "typescript", - "version": 1, - "text": "import * as a from \"https://localhost:5545/xTypeScriptTypes.js\";\n// @deno-types=\"https://localhost:5545/type_definitions/foo.d.ts\"\nimport * as b from \"https://localhost:5545/type_definitions/foo.js\";\nimport * as c from \"https://localhost:5545/subdir/type_reference.js\";\nimport * as d from \"https://localhost:5545/subdir/mod1.ts\";\nimport * as e from \"data:application/typescript;base64,ZXhwb3J0IGNvbnN0IGEgPSAiYSI7CgpleHBvcnQgZW51bSBBIHsKICBBLAogIEIsCiAgQywKfQo=\";\nimport * as f from \"./file_01.ts\";\nimport * as g from \"http://localhost:4545/x/a/mod.ts\";\n\nconsole.log(a, b, c, d, e, f, g);\n" - } -} diff --git a/cli/tests/testdata/lsp/document_symbol_response.json b/cli/tests/testdata/lsp/document_symbol_response.json deleted file mode 100644 index 90dd76411..000000000 --- a/cli/tests/testdata/lsp/document_symbol_response.json +++ /dev/null @@ -1,371 +0,0 @@ -[ - { - "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": 8, - "range": { - "start": { - "line": 11, - "character": 2 - }, - "end": { - "line": 11, - "character": 32 - } - }, - "selectionRange": { - "start": { - "line": 11, - "character": 9 - }, - "end": { - "line": 11, - "character": 18 - } - } - }, - { - "name": "(get) value", - "kind": 8, - "range": { - "start": { - "line": 9, - "character": 2 - }, - "end": { - "line": 9, - "character": 35 - } - }, - "selectionRange": { - "start": { - "line": 9, - "character": 6 - }, - "end": { - "line": 9, - "character": 11 - } - } - }, - { - "name": "(set) value", - "kind": 8, - "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": 8, - "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": 22, - "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": 22, - "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 deleted file mode 100644 index 1c0b9f8e8..000000000 --- a/cli/tests/testdata/lsp/formatting_mbc_response.json +++ /dev/null @@ -1,54 +0,0 @@ -[ - { - "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-completions.json b/cli/tests/testdata/lsp/import-map-completions.json deleted file mode 100644 index f2275222a..000000000 --- a/cli/tests/testdata/lsp/import-map-completions.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "imports": { - "/~/": "./lib/", - "fs": "https://example.com/fs/index.js", - "std/": "https://example.com/std@0.123.0/" - } -} diff --git a/cli/tests/testdata/lsp/incoming_calls_params.json b/cli/tests/testdata/lsp/incoming_calls_params.json deleted file mode 100644 index 6b38d26ee..000000000 --- a/cli/tests/testdata/lsp/incoming_calls_params.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "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 deleted file mode 100644 index 231919a8c..000000000 --- a/cli/tests/testdata/lsp/incoming_calls_response.json +++ /dev/null @@ -1,42 +0,0 @@ -[ - { - "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 deleted file mode 100644 index 68735b06d..000000000 --- a/cli/tests/testdata/lsp/initialize_params.json +++ /dev/null @@ -1,82 +0,0 @@ -{ - "processId": 0, - "clientInfo": { - "name": "test-harness", - "version": "1.0.0" - }, - "rootUri": null, - "initializationOptions": { - "enable": true, - "cache": null, - "certificateStores": null, - "codeLens": { - "implementations": true, - "references": true, - "test": true - }, - "config": null, - "importMap": null, - "lint": true, - "suggest": { - "autoImports": true, - "completeFunctionCalls": false, - "names": true, - "paths": true, - "imports": { - "hosts": {} - } - }, - "testing": { - "args": [ - "--allow-all" - ], - "enable": true - }, - "tlsCertificate": null, - "unsafelyIgnoreCertificateErrors": null, - "unstable": false - }, - "capabilities": { - "textDocument": { - "codeAction": { - "codeActionLiteralSupport": { - "codeActionKind": { - "valueSet": [ - "quickfix", - "refactor" - ] - } - }, - "isPreferredSupport": true, - "dataSupport": true, - "disabledSupport": true, - "resolveSupport": { - "properties": [ - "edit" - ] - } - }, - "completion": { - "completionItem": { - "snippetSupport": true - } - }, - "foldingRange": { - "lineFoldingOnly": true - }, - "synchronization": { - "dynamicRegistration": true, - "willSave": true, - "willSaveWaitUntil": true, - "didSave": true - } - }, - "workspace": { - "configuration": true, - "workspaceFolders": true - }, - "experimental": { - "testingApi": 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 deleted file mode 100644 index 053cb70f3..000000000 --- a/cli/tests/testdata/lsp/initialize_params_bad_config_option.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "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 deleted file mode 100644 index 3df87aded..000000000 --- a/cli/tests/testdata/lsp/initialize_params_ca_no_disabled.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "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 deleted file mode 100644 index bdd01bfca..000000000 --- a/cli/tests/testdata/lsp/initialize_params_code_lens_test.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "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 deleted file mode 100644 index 1d18934ae..000000000 --- a/cli/tests/testdata/lsp/initialize_params_code_lens_test_disabled.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "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 deleted file mode 100644 index 870ad6e0f..000000000 --- a/cli/tests/testdata/lsp/initialize_params_did_config_change.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "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 deleted file mode 100644 index 879b1181c..000000000 --- a/cli/tests/testdata/lsp/initialize_params_disabled.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "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_hints.json b/cli/tests/testdata/lsp/initialize_params_hints.json deleted file mode 100644 index 1bab6e86d..000000000 --- a/cli/tests/testdata/lsp/initialize_params_hints.json +++ /dev/null @@ -1,102 +0,0 @@ -{ - "processId": 0, - "clientInfo": { - "name": "test-harness", - "version": "1.0.0" - }, - "rootUri": null, - "initializationOptions": { - "enable": true, - "cache": null, - "certificateStores": null, - "codeLens": { - "implementations": true, - "references": true, - "test": true - }, - "config": null, - "importMap": null, - "inlayHints": { - "parameterNames": { - "enabled": "all" - }, - "parameterTypes": { - "enabled": true - }, - "variableTypes": { - "enabled": true - }, - "propertyDeclarationTypes": { - "enabled": true - }, - "functionLikeReturnTypes": { - "enabled": true - }, - "enumMemberValues": { - "enabled": true - } - }, - "lint": true, - "suggest": { - "autoImports": true, - "completeFunctionCalls": false, - "names": true, - "paths": true, - "imports": { - "hosts": {} - } - }, - "testing": { - "args": [ - "--allow-all" - ], - "enable": true - }, - "tlsCertificate": null, - "unsafelyIgnoreCertificateErrors": null, - "unstable": false - }, - "capabilities": { - "textDocument": { - "codeAction": { - "codeActionLiteralSupport": { - "codeActionKind": { - "valueSet": [ - "quickfix", - "refactor" - ] - } - }, - "isPreferredSupport": true, - "dataSupport": true, - "disabledSupport": true, - "resolveSupport": { - "properties": [ - "edit" - ] - } - }, - "completion": { - "completionItem": { - "snippetSupport": true - } - }, - "foldingRange": { - "lineFoldingOnly": true - }, - "synchronization": { - "dynamicRegistration": true, - "willSave": true, - "willSaveWaitUntil": true, - "didSave": true - } - }, - "workspace": { - "configuration": true, - "workspaceFolders": true - }, - "experimental": { - "testingApi": true - } - } -} diff --git a/cli/tests/testdata/lsp/initialize_params_import_map.json b/cli/tests/testdata/lsp/initialize_params_import_map.json deleted file mode 100644 index 2ba7d28b0..000000000 --- a/cli/tests/testdata/lsp/initialize_params_import_map.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "processId": 0, - "clientInfo": { - "name": "test-harness", - "version": "1.0.0" - }, - "rootUri": null, - "initializationOptions": { - "enable": true, - "codeLens": { - "implementations": true, - "references": true - }, - "importMap": "data:application/json;utf8,{\"imports\": { \"example\": \"https://deno.land/x/example/mod.ts\" }}", - "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" - ] - } - }, - "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_no_snippet.json b/cli/tests/testdata/lsp/initialize_params_no_snippet.json deleted file mode 100644 index b076f3b17..000000000 --- a/cli/tests/testdata/lsp/initialize_params_no_snippet.json +++ /dev/null @@ -1,77 +0,0 @@ -{ - "processId": 0, - "clientInfo": { - "name": "test-harness", - "version": "1.0.0" - }, - "rootUri": null, - "initializationOptions": { - "enable": true, - "cache": null, - "certificateStores": null, - "codeLens": { - "implementations": true, - "references": true, - "test": true - }, - "config": null, - "importMap": null, - "lint": true, - "suggest": { - "autoImports": true, - "completeFunctionCalls": false, - "names": true, - "paths": true, - "imports": { - "hosts": {} - } - }, - "testing": { - "args": [ - "--allow-all" - ], - "enable": true - }, - "tlsCertificate": null, - "unsafelyIgnoreCertificateErrors": null, - "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 - }, - "experimental": { - "testingApi": true - } - } -} diff --git a/cli/tests/testdata/lsp/initialize_params_registry.json b/cli/tests/testdata/lsp/initialize_params_registry.json deleted file mode 100644 index 286f6085f..000000000 --- a/cli/tests/testdata/lsp/initialize_params_registry.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "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": { - "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_tls_cert.json b/cli/tests/testdata/lsp/initialize_params_tls_cert.json deleted file mode 100644 index e231bf25f..000000000 --- a/cli/tests/testdata/lsp/initialize_params_tls_cert.json +++ /dev/null @@ -1,71 +0,0 @@ -{ - "processId": 0, - "clientInfo": { - "name": "test-harness", - "version": "1.0.0" - }, - "rootUri": null, - "initializationOptions": { - "enable": true, - "cache": null, - "certificateStores": null, - "codeLens": { - "implementations": true, - "references": true, - "test": true - }, - "config": "", - "importMap": null, - "lint": true, - "suggest": { - "autoImports": true, - "completeFunctionCalls": false, - "names": true, - "paths": true, - "imports": { - "hosts": { - "https://localhost:5545": true, - "http://localhost:4545": true - } - } - }, - "tlsCertificate": "tls/RootCA.pem", - "unsafelyIgnoreCertificateErrors": null, - "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 deleted file mode 100644 index 104db16f2..000000000 --- a/cli/tests/testdata/lsp/initialize_params_unstable.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "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/initialize_params_workspace_enable_paths.json b/cli/tests/testdata/lsp/initialize_params_workspace_enable_paths.json deleted file mode 100644 index 87581ebd7..000000000 --- a/cli/tests/testdata/lsp/initialize_params_workspace_enable_paths.json +++ /dev/null @@ -1,77 +0,0 @@ -{ - "processId": 0, - "clientInfo": { - "name": "test-harness", - "version": "1.0.0" - }, - "rootUri": "file:///project/", - "initializationOptions": { - "enable": false, - "enablePaths": [ - "./worker" - ], - "cache": null, - "certificateStores": null, - "codeLens": { - "implementations": true, - "references": true, - "test": true - }, - "config": "", - "importMap": null, - "lint": true, - "suggest": { - "autoImports": true, - "completeFunctionCalls": false, - "names": true, - "paths": true, - "imports": { - "hosts": {} - } - }, - "tlsCertificate": null, - "unsafelyIgnoreCertificateErrors": null, - "unstable": false - }, - "workspaceFolders": [ - { - "uri": "file:///project/", - "name": "project" - } - ], - "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/large_file.txt b/cli/tests/testdata/lsp/large_file.txt new file mode 100644 index 000000000..f1ca0481c --- /dev/null +++ b/cli/tests/testdata/lsp/large_file.txt @@ -0,0 +1,676 @@ +// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. + +// @ts-check +/// <reference path="./compiler.d.ts" /> +// deno-lint-ignore-file no-undef + +// This module is the entry point for "compiler" isolate, ie. the one +// that is created when Deno needs to type check TypeScript, and in some +// instances convert TypeScript to JavaScript. + +// Removes the `__proto__` for security reasons. This intentionally makes +// Deno non compliant with ECMA-262 Annex B.2.2.1 +delete Object.prototype.__proto__; + +((window) => { + /** @type {DenoCore} */ + const core = window.Deno.core; + + let logDebug = false; + let logSource = "JS"; + + function setLogDebug(debug, source) { + logDebug = debug; + if (source) { + logSource = source; + } + } + + function debug(...args) { + if (logDebug) { + const stringifiedArgs = args.map((arg) => + typeof arg === "string" ? arg : JSON.stringify(arg) + ).join(" "); + // adding a non-zero integer value to the end of the debug string causes + // the message to be printed to stderr instead of stdout, which is better + // aligned to the behaviour of debug messages + core.print(`DEBUG ${logSource} - ${stringifiedArgs}\n`, 1); + } + } + + function error(...args) { + const stringifiedArgs = args.map((arg) => + typeof arg === "string" || arg instanceof Error + ? String(arg) + : JSON.stringify(arg) + ).join(" "); + core.print(`ERROR ${logSource} = ${stringifiedArgs}\n`, 1); + } + + class AssertionError extends Error { + constructor(msg) { + super(msg); + this.name = "AssertionError"; + } + } + + function assert(cond, msg = "Assertion failed.") { + if (!cond) { + throw new AssertionError(msg); + } + } + + /** @type {Map<string, ts.SourceFile>} */ + const sourceFileCache = new Map(); + + /** @param {ts.DiagnosticRelatedInformation} diagnostic */ + function fromRelatedInformation({ + start, + length, + file, + messageText: msgText, + ...ri + }) { + let messageText; + let messageChain; + if (typeof msgText === "object") { + messageChain = msgText; + } else { + messageText = msgText; + } + if (start !== undefined && length !== undefined && file) { + const startPos = file.getLineAndCharacterOfPosition(start); + const sourceLine = file.getFullText().split("\n")[startPos.line]; + const fileName = file.fileName; + return { + start: startPos, + end: file.getLineAndCharacterOfPosition(start + length), + fileName, + messageChain, + messageText, + sourceLine, + ...ri, + }; + } else { + return { + messageChain, + messageText, + ...ri, + }; + } + } + + /** @param {ts.Diagnostic[]} diagnostics */ + function fromTypeScriptDiagnostic(diagnostics) { + return diagnostics.map(({ relatedInformation: ri, source, ...diag }) => { + /** @type {any} */ + const value = fromRelatedInformation(diag); + value.relatedInformation = ri + ? ri.map(fromRelatedInformation) + : undefined; + value.source = source; + return value; + }); + } + + // Using incremental compile APIs requires that all + // paths must be either relative or absolute. Since + // analysis in Rust operates on fully resolved URLs, + // it makes sense to use the same scheme here. + const ASSETS = "asset:///"; + const CACHE = "cache:///"; + + /** Diagnostics that are intentionally ignored when compiling TypeScript in + * Deno, as they provide misleading or incorrect information. */ + const IGNORED_DIAGNOSTICS = [ + // TS1208: All files must be modules when the '--isolatedModules' flag is + // provided. We can ignore because we guarantee that all files are + // modules. + 1208, + // TS1375: 'await' expressions are only allowed at the top level of a file + // when that file is a module, but this file has no imports or exports. + // Consider adding an empty 'export {}' to make this file a module. + 1375, + // TS1103: 'for-await-of' statement is only allowed within an async function + // or async generator. + 1103, + // TS2306: File 'file:///Users/rld/src/deno/subdir/amd_like.js' is + // not a module. + 2306, + // TS2691: An import path cannot end with a '.ts' extension. Consider + // importing 'bad-module' instead. + 2691, + // TS2792: Cannot find module. Did you mean to set the 'moduleResolution' + // option to 'node', or to add aliases to the 'paths' option? + 2792, + // TS5009: Cannot find the common subdirectory path for the input files. + 5009, + // TS5055: Cannot write file + // 'http://localhost:4545/subdir/mt_application_x_javascript.j4.js' + // because it would overwrite input file. + 5055, + // TypeScript is overly opinionated that only CommonJS modules kinds can + // support JSON imports. Allegedly this was fixed in + // Microsoft/TypeScript#26825 but that doesn't seem to be working here, + // so we will ignore complaints about this compiler setting. + 5070, + // TS7016: Could not find a declaration file for module '...'. '...' + // implicitly has an 'any' type. This is due to `allowJs` being off by + // default but importing of a JavaScript module. + 7016, + ]; + + const SNAPSHOT_COMPILE_OPTIONS = { + esModuleInterop: true, + jsx: ts.JsxEmit.React, + module: ts.ModuleKind.ESNext, + noEmit: true, + strict: true, + target: ts.ScriptTarget.ESNext, + }; + + class ScriptSnapshot { + /** @type {string} */ + specifier; + /** @type {string} */ + version; + /** + * @param {string} specifier + * @param {string} version + */ + constructor(specifier, version) { + this.specifier = specifier; + this.version = version; + } + /** + * @param {number} start + * @param {number} end + * @returns {string} + */ + getText(start, end) { + const { specifier, version } = this; + debug( + `snapshot.getText(${start}, ${end}) specifier: ${specifier} version: ${version}`, + ); + return core.jsonOpSync("op_get_text", { specifier, version, start, end }); + } + /** + * @returns {number} + */ + getLength() { + const { specifier, version } = this; + debug(`snapshot.getLength() specifier: ${specifier} version: ${version}`); + return core.jsonOpSync("op_get_length", { specifier, version }); + } + /** + * @param {ScriptSnapshot} oldSnapshot + * @returns {ts.TextChangeRange | undefined} + */ + getChangeRange(oldSnapshot) { + const { specifier, version } = this; + const { version: oldVersion } = oldSnapshot; + const oldLength = oldSnapshot.getLength(); + debug( + `snapshot.getLength() specifier: ${specifier} oldVersion: ${oldVersion} version: ${version}`, + ); + return core.jsonOpSync( + "op_get_change_range", + { specifier, oldLength, oldVersion, version }, + ); + } + dispose() { + const { specifier, version } = this; + debug(`snapshot.dispose() specifier: ${specifier} version: ${version}`); + core.jsonOpSync("op_dispose", { specifier, version }); + } + } + + /** @type {ts.CompilerOptions} */ + let compilationSettings = {}; + + /** @type {ts.LanguageService} */ + let languageService; + + /** An object literal of the incremental compiler host, which provides the + * specific "bindings" to the Deno environment that tsc needs to work. + * + * @type {ts.CompilerHost & ts.LanguageServiceHost} */ + const host = { + fileExists(fileName) { + debug(`host.fileExists("${fileName}")`); + return false; + }, + readFile(specifier) { + debug(`host.readFile("${specifier}")`); + return core.jsonOpSync("op_load", { specifier }).data; + }, + getSourceFile( + specifier, + languageVersion, + _onError, + _shouldCreateNewSourceFile, + ) { + debug( + `host.getSourceFile("${specifier}", ${ + ts.ScriptTarget[languageVersion] + })`, + ); + let sourceFile = sourceFileCache.get(specifier); + if (sourceFile) { + return sourceFile; + } + + /** @type {{ data: string; hash?: string; scriptKind: ts.ScriptKind }} */ + const { data, hash, scriptKind } = core.jsonOpSync( + "op_load", + { specifier }, + ); + assert( + data != null, + `"data" is unexpectedly null for "${specifier}".`, + ); + sourceFile = ts.createSourceFile( + specifier, + data, + languageVersion, + false, + scriptKind, + ); + sourceFile.moduleName = specifier; + sourceFile.version = hash; + sourceFileCache.set(specifier, sourceFile); + return sourceFile; + }, + getDefaultLibFileName() { + return `${ASSETS}/lib.esnext.d.ts`; + }, + getDefaultLibLocation() { + return ASSETS; + }, + writeFile(fileName, data, _writeByteOrderMark, _onError, sourceFiles) { + debug(`host.writeFile("${fileName}")`); + let maybeSpecifiers; + if (sourceFiles) { + maybeSpecifiers = sourceFiles.map((sf) => sf.moduleName); + } + return core.jsonOpSync( + "op_emit", + { maybeSpecifiers, fileName, data }, + ); + }, + getCurrentDirectory() { + return CACHE; + }, + getCanonicalFileName(fileName) { + return fileName; + }, + useCaseSensitiveFileNames() { + return true; + }, + getNewLine() { + return "\n"; + }, + resolveModuleNames(specifiers, base) { + debug(`host.resolveModuleNames()`); + debug(` base: ${base}`); + debug(` specifiers: ${specifiers.join(", ")}`); + /** @type {Array<[string, ts.Extension] | undefined>} */ + const resolved = core.jsonOpSync("op_resolve", { + specifiers, + base, + }); + if (resolved) { + const result = resolved.map((item) => { + if (item) { + const [resolvedFileName, extension] = item; + return { + resolvedFileName, + extension, + isExternalLibraryImport: false, + }; + } + return undefined; + }); + result.length = specifiers.length; + return result; + } else { + return new Array(specifiers.length); + } + }, + createHash(data) { + return core.jsonOpSync("op_create_hash", { data }).hash; + }, + + // LanguageServiceHost + getCompilationSettings() { + debug("host.getCompilationSettings()"); + return compilationSettings; + }, + getScriptFileNames() { + debug("host.getScriptFileNames()"); + return core.jsonOpSync("op_script_names", undefined); + }, + getScriptVersion(specifier) { + debug(`host.getScriptVersion("${specifier}")`); + const sourceFile = sourceFileCache.get(specifier); + if (sourceFile) { + return sourceFile.version ?? "1"; + } + return core.jsonOpSync("op_script_version", { specifier }); + }, + getScriptSnapshot(specifier) { + debug(`host.getScriptSnapshot("${specifier}")`); + const sourceFile = sourceFileCache.get(specifier); + if (sourceFile) { + return { + getText(start, end) { + return sourceFile.text.substring(start, end); + }, + getLength() { + return sourceFile.text.length; + }, + getChangeRange() { + return undefined; + }, + }; + } + /** @type {string | undefined} */ + const version = core.jsonOpSync("op_script_version", { specifier }); + if (version != null) { + return new ScriptSnapshot(specifier, version); + } + return undefined; + }, + }; + + /** @type {Array<[string, number]>} */ + const stats = []; + let statsStart = 0; + + function performanceStart() { + stats.length = 0; + statsStart = Date.now(); + ts.performance.enable(); + } + + /** + * @param {{ program: ts.Program | ts.EmitAndSemanticDiagnosticsBuilderProgram, fileCount?: number }} options + */ + function performanceProgram({ program, fileCount }) { + if (program) { + if ("getProgram" in program) { + program = program.getProgram(); + } + stats.push(["Files", program.getSourceFiles().length]); + stats.push(["Nodes", program.getNodeCount()]); + stats.push(["Identifiers", program.getIdentifierCount()]); + stats.push(["Symbols", program.getSymbolCount()]); + stats.push(["Types", program.getTypeCount()]); + stats.push(["Instantiations", program.getInstantiationCount()]); + } else if (fileCount != null) { + stats.push(["Files", fileCount]); + } + const programTime = ts.performance.getDuration("Program"); + const bindTime = ts.performance.getDuration("Bind"); + const checkTime = ts.performance.getDuration("Check"); + const emitTime = ts.performance.getDuration("Emit"); + stats.push(["Parse time", programTime]); + stats.push(["Bind time", bindTime]); + stats.push(["Check time", checkTime]); + stats.push(["Emit time", emitTime]); + stats.push( + ["Total TS time", programTime + bindTime + checkTime + emitTime], + ); + } + + function performanceEnd() { + const duration = Date.now() - statsStart; + stats.push(["Compile time", duration]); + return stats; + } + + /** + * @typedef {object} Request + * @property {Record<string, any>} config + * @property {boolean} debug + * @property {string[]} rootNames + */ + + /** The API that is called by Rust when executing a request. + * @param {Request} request + */ + function exec({ config, debug: debugFlag, rootNames }) { + setLogDebug(debugFlag, "TS"); + performanceStart(); + debug(">>> exec start", { rootNames }); + debug(config); + + const { options, errors: configFileParsingDiagnostics } = ts + .convertCompilerOptionsFromJson(config, ""); + // The `allowNonTsExtensions` is a "hidden" compiler option used in VSCode + // which is not allowed to be passed in JSON, we need it to allow special + // URLs which Deno supports. So we need to either ignore the diagnostic, or + // inject it ourselves. + Object.assign(options, { allowNonTsExtensions: true }); + const program = ts.createIncrementalProgram({ + rootNames, + options, + host, + configFileParsingDiagnostics, + }); + + const { diagnostics: emitDiagnostics } = program.emit(); + + const diagnostics = [ + ...program.getConfigFileParsingDiagnostics(), + ...program.getSyntacticDiagnostics(), + ...program.getOptionsDiagnostics(), + ...program.getGlobalDiagnostics(), + ...program.getSemanticDiagnostics(), + ...emitDiagnostics, + ].filter(({ code }) => !IGNORED_DIAGNOSTICS.includes(code)); + performanceProgram({ program }); + + core.jsonOpSync("op_respond", { + diagnostics: fromTypeScriptDiagnostic(diagnostics), + stats: performanceEnd(), + }); + debug("<<< exec stop"); + } + + /** + * @param {number} id + * @param {any} data + */ + function respond(id, data = null) { + core.jsonOpSync("op_respond", { id, data }); + } + + /** + * @param {LanguageServerRequest} request + */ + function serverRequest({ id, ...request }) { + debug(`serverRequest()`, { id, ...request }); + switch (request.method) { + case "configure": { + const { options, errors } = ts + .convertCompilerOptionsFromJson(request.compilerOptions, ""); + Object.assign(options, { allowNonTsExtensions: true }); + if (errors.length) { + debug(ts.formatDiagnostics(errors, host)); + } + compilationSettings = options; + return respond(id, true); + } + case "getAsset": { + const sourceFile = host.getSourceFile( + request.specifier, + ts.ScriptTarget.ESNext, + ); + return respond(id, sourceFile && sourceFile.text); + } + case "getDiagnostics": { + try { + /** @type {Record<string, any[]>} */ + const diagnosticMap = {}; + for (const specifier of request.specifiers) { + diagnosticMap[specifier] = fromTypeScriptDiagnostic([ + ...languageService.getSemanticDiagnostics(specifier), + ...languageService.getSuggestionDiagnostics(specifier), + ...languageService.getSyntacticDiagnostics(specifier), + ].filter(({ code }) => !IGNORED_DIAGNOSTICS.includes(code))); + } + return respond(id, diagnosticMap); + } catch (e) { + if ("stack" in e) { + error(e.stack); + } else { + error(e); + } + return respond(id, {}); + } + } + case "getQuickInfo": { + return respond( + id, + languageService.getQuickInfoAtPosition( + request.specifier, + request.position, + ), + ); + } + case "getCompletions": { + return respond( + id, + languageService.getCompletionsAtPosition( + request.specifier, + request.position, + request.preferences, + ), + ); + } + case "getDocumentHighlights": { + return respond( + id, + languageService.getDocumentHighlights( + request.specifier, + request.position, + request.filesToSearch, + ), + ); + } + case "getReferences": { + return respond( + id, + languageService.getReferencesAtPosition( + request.specifier, + request.position, + ), + ); + } + case "getDefinition": { + return respond( + id, + languageService.getDefinitionAndBoundSpan( + request.specifier, + request.position, + ), + ); + } + case "getImplementation": { + return respond( + id, + languageService.getImplementationAtPosition( + request.specifier, + request.position, + ), + ); + } + case "findRenameLocations": { + return respond( + id, + languageService.findRenameLocations( + request.specifier, + request.position, + request.findInStrings, + request.findInComments, + request.providePrefixAndSuffixTextForRename, + ), + ); + } + default: + throw new TypeError( + // @ts-ignore exhausted case statement sets type to never + `Invalid request method for request: "${request.method}" (${id})`, + ); + } + } + + /** @param {{ debug: boolean; }} init */ + function serverInit({ debug: debugFlag }) { + if (hasStarted) { + throw new Error("The language server has already been initialized."); + } + hasStarted = true; + languageService = ts.createLanguageService(host); + core.ops(); + setLogDebug(debugFlag, "TSLS"); + debug("serverInit()"); + } + + let hasStarted = false; + + /** Startup the runtime environment, setting various flags. + * @param {{ debugFlag?: boolean; legacyFlag?: boolean; }} msg + */ + function startup({ debugFlag = false }) { + if (hasStarted) { + throw new Error("The compiler runtime already started."); + } + hasStarted = true; + core.ops(); + setLogDebug(!!debugFlag, "TS"); + } + + // Setup the compiler runtime during the build process. + core.ops(); + core.registerErrorClass("Error", Error); + + // A build time only op that provides some setup information that is used to + // ensure the snapshot is setup properly. + /** @type {{ buildSpecifier: string; libs: string[] }} */ + const { buildSpecifier, libs } = core.jsonOpSync("op_build_info", {}); + for (const lib of libs) { + const specifier = `lib.${lib}.d.ts`; + // we are using internal APIs here to "inject" our custom libraries into + // tsc, so things like `"lib": [ "deno.ns" ]` are supported. + if (!ts.libs.includes(lib)) { + ts.libs.push(lib); + ts.libMap.set(lib, `lib.${lib}.d.ts`); + } + // we are caching in memory common type libraries that will be re-used by + // tsc on when the snapshot is restored + assert( + host.getSourceFile(`${ASSETS}${specifier}`, ts.ScriptTarget.ESNext), + ); + } + // this helps ensure as much as possible is in memory that is re-usable + // before the snapshotting is done, which helps unsure fast "startup" for + // subsequent uses of tsc in Deno. + const TS_SNAPSHOT_PROGRAM = ts.createProgram({ + rootNames: [buildSpecifier], + options: SNAPSHOT_COMPILE_OPTIONS, + host, + }); + ts.getPreEmitDiagnostics(TS_SNAPSHOT_PROGRAM); + + // exposes the two functions that are called by `tsc::exec()` when type + // checking TypeScript. + globalThis.startup = startup; + globalThis.exec = exec; + + // exposes the functions that are called when the compiler is used as a + // language service. + globalThis.serverInit = serverInit; + globalThis.serverRequest = serverRequest; +})(this); diff --git a/cli/tests/testdata/lsp/lib.tsconfig.json b/cli/tests/testdata/lsp/lib.tsconfig.json deleted file mode 100644 index 8d2ae8a8b..000000000 --- a/cli/tests/testdata/lsp/lib.tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "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 deleted file mode 100644 index 6b38d26ee..000000000 --- a/cli/tests/testdata/lsp/outgoing_calls_params.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "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 deleted file mode 100644 index c7cf85cf8..000000000 --- a/cli/tests/testdata/lsp/outgoing_calls_response.json +++ /dev/null @@ -1,42 +0,0 @@ -[ - { - "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 deleted file mode 100644 index 93a7d4f1b..000000000 --- a/cli/tests/testdata/lsp/prepare_call_hierarchy_response.json +++ /dev/null @@ -1,28 +0,0 @@ -[ - { - "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/rename_response.json b/cli/tests/testdata/lsp/rename_response.json deleted file mode 100644 index 5e0e28e4c..000000000 --- a/cli/tests/testdata/lsp/rename_response.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "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 deleted file mode 100644 index c5a8b288e..000000000 --- a/cli/tests/testdata/lsp/selection_range_response.json +++ /dev/null @@ -1,98 +0,0 @@ -[ - { - "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": 12 - }, - "end": { - "line": 6, - "character": 3 - } - }, - "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 - } - } - } - } - } - } - } - } - } - } -] |
