diff options
author | Kitson Kelly <me@kitsonkelly.com> | 2021-11-23 11:09:19 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-23 11:09:19 +1100 |
commit | 210300d0497005f74d64a1d028e1becbae9f27e8 (patch) | |
tree | 982d0ea9bf52a24b82f6743f6ced98cf037527e1 /cli/tests/integration/lsp_tests.rs | |
parent | bf5657cd590a0624d614a09ff6fc3538f94643da (diff) |
feat(lsp): add type definition provider (#12789)
Diffstat (limited to 'cli/tests/integration/lsp_tests.rs')
-rw-r--r-- | cli/tests/integration/lsp_tests.rs | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/cli/tests/integration/lsp_tests.rs b/cli/tests/integration/lsp_tests.rs index 8e7de0286..3d55ac28c 100644 --- a/cli/tests/integration/lsp_tests.rs +++ b/cli/tests/integration/lsp_tests.rs @@ -1267,6 +1267,66 @@ fn lsp_hover_typescript_types() { } #[test] +fn lsp_goto_type_definition() { + let mut client = init("initialize_params.json"); + did_open( + &mut client, + json!({ + "textDocument": { + "uri": "file:///a/file.ts", + "languageId": "typescript", + "version": 1, + "text": "interface A {\n a: string;\n}\n\nexport class B implements A {\n a = \"a\";\n log() {\n console.log(this.a);\n }\n}\n\nconst b = new B();\nb;\n", + } + }), + ); + let (maybe_res, maybe_error) = client + .write_request::<_, _, Value>( + "textDocument/typeDefinition", + json!({ + "textDocument": { + "uri": "file:///a/file.ts" + }, + "position": { + "line": 12, + "character": 1 + } + }), + ) + .unwrap(); + assert!(maybe_error.is_none()); + assert_eq!( + maybe_res, + Some(json!([ + { + "targetUri": "file:///a/file.ts", + "targetRange": { + "start": { + "line": 4, + "character": 0 + }, + "end": { + "line": 9, + "character": 1 + } + }, + "targetSelectionRange": { + "start": { + "line": 4, + "character": 13 + }, + "end": { + "line": 4, + "character": 14 + } + } + } + ])) + ); + shutdown(&mut client); +} + +#[test] fn lsp_call_hierarchy() { let mut client = init("initialize_params.json"); did_open( |