From 2f2c778a074d0eff991c6c22da54429de3de6704 Mon Sep 17 00:00:00 2001 From: Kitson Kelly Date: Thu, 10 Feb 2022 10:08:53 +1100 Subject: feat(lsp): support linking to symbols in JSDoc on hover (#13631) Closes #13198 --- cli/tests/integration/lsp_tests.rs | 65 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) (limited to 'cli/tests/integration') diff --git a/cli/tests/integration/lsp_tests.rs b/cli/tests/integration/lsp_tests.rs index d45b90955..2a5304dfc 100644 --- a/cli/tests/integration/lsp_tests.rs +++ b/cli/tests/integration/lsp_tests.rs @@ -1660,6 +1660,71 @@ fn lsp_hover_typescript_types() { shutdown(&mut client); } +#[test] +fn lsp_hover_jsdoc_symbol_link() { + let mut client = init("initialize_params.json"); + did_open( + &mut client, + json!({ + "textDocument": { + "uri": "file:///a/b.ts", + "languageId": "typescript", + "version": 1, + "text": "export function hello() {}\n" + } + }), + ); + did_open( + &mut client, + json!({ + "textDocument": { + "uri": "file:///a/file.ts", + "languageId": "typescript", + "version": 1, + "text": "import { hello } from \"./b.ts\";\n\nhello();\n\nconst b = \"b\";\n\n/** JSDoc {@link hello} and {@linkcode b} */\nfunction a() {}\n" + } + }), + ); + let (maybe_res, maybe_err) = client + .write_request::<_, _, Value>( + "textDocument/hover", + json!({ + "textDocument": { + "uri": "file:///a/file.ts" + }, + "position": { + "line": 7, + "character": 10 + } + }), + ) + .unwrap(); + assert!(maybe_err.is_none()); + assert_eq!( + maybe_res, + Some(json!({ + "contents": [ + { + "language": "typescript", + "value": "function a(): void" + }, + "JSDoc [hello](file:///a/b.ts#L1,1) and [`b`](file:///a/file.ts#L5,7)" + ], + "range": { + "start": { + "line": 7, + "character": 9 + }, + "end": { + "line": 7, + "character": 10 + } + } + })) + ); + shutdown(&mut client); +} + #[test] fn lsp_goto_type_definition() { let mut client = init("initialize_params.json"); -- cgit v1.2.3