1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-21 15:04:11 -05:00

fix(lsp): show reference code lens on methods (#23804)

This commit is contained in:
Nayeem Rahman 2024-05-14 22:42:35 +01:00 committed by GitHub
parent e39b94f3aa
commit dda8979cb1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 113 additions and 4 deletions

View file

@ -505,6 +505,7 @@ pub fn collect_tsc(
));
}
tsc::ScriptElementKind::LocalFunctionElement
| tsc::ScriptElementKind::MemberFunctionElement
| tsc::ScriptElementKind::MemberGetAccessorElement
| tsc::ScriptElementKind::MemberSetAccessorElement
| tsc::ScriptElementKind::ConstructorImplementationElement

View file

@ -3509,10 +3509,18 @@ fn lsp_semantic_tokens() {
}
#[test]
fn lsp_code_lens() {
fn lsp_code_lens_references() {
let context = TestContextBuilder::new().use_temp_cwd().build();
let mut client = context.new_lsp_command().build();
client.initialize_default();
client.change_configuration(json!({
"deno": {
"enable": true,
"codeLens": {
"references": true,
}
},
}));
client.did_open(json!({
"textDocument": {
"uri": "file:///a/file.ts",
@ -3567,6 +3575,24 @@ fn lsp_code_lens() {
"specifier": "file:///a/file.ts",
"source": "references"
}
}, {
"range": {
"start": { "line": 3, "character": 2 },
"end": { "line": 3, "character": 3 }
},
"data": {
"specifier": "file:///a/file.ts",
"source": "references"
}
}, {
"range": {
"start": { "line": 7, "character": 2 },
"end": { "line": 7, "character": 3 }
},
"data": {
"specifier": "file:///a/file.ts",
"source": "references"
}
}])
);
let res = client.write_request(
@ -3684,10 +3710,19 @@ fn lsp_code_lens() {
}
#[test]
fn lsp_code_lens_impl() {
fn lsp_code_lens_implementations() {
let context = TestContextBuilder::new().use_temp_cwd().build();
let mut client = context.new_lsp_command().build();
client.initialize_default();
client.change_configuration(json!({
"deno": {
"enable": true,
"codeLens": {
"implementations": true,
"references": true,
}
},
}));
client.did_open(
json!({
"textDocument": {
@ -3726,6 +3761,15 @@ fn lsp_code_lens_impl() {
"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"
}
}, {
"range": {
"start": { "line": 4, "character": 6 },
@ -3735,6 +3779,15 @@ fn lsp_code_lens_impl() {
"specifier": "file:///a/file.ts",
"source": "references"
}
}, {
"range": {
"start": { "line": 5, "character": 2 },
"end": { "line": 5, "character": 3 }
},
"data": {
"specifier": "file:///a/file.ts",
"source": "references"
}
}, {
"range": {
"start": { "line": 10, "character": 10 },
@ -4130,6 +4183,15 @@ fn lsp_code_lens_non_doc_nav_tree() {
let context = TestContextBuilder::new().use_temp_cwd().build();
let mut client = context.new_lsp_command().build();
client.initialize_default();
client.change_configuration(json!({
"deno": {
"enable": true,
"codeLens": {
"implementations": true,
"references": true,
}
},
}));
client.did_open(json!({
"textDocument": {
"uri": "file:///a/file.ts",
@ -4188,6 +4250,15 @@ fn lsp_nav_tree_updates() {
let context = TestContextBuilder::new().use_temp_cwd().build();
let mut client = context.new_lsp_command().build();
client.initialize_default();
client.change_configuration(json!({
"deno": {
"enable": true,
"codeLens": {
"implementations": true,
"references": true,
}
},
}));
client.did_open(
json!({
"textDocument": {
@ -4226,6 +4297,15 @@ fn lsp_nav_tree_updates() {
"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"
}
}, {
"range": {
"start": { "line": 4, "character": 6 },
@ -4235,6 +4315,15 @@ fn lsp_nav_tree_updates() {
"specifier": "file:///a/file.ts",
"source": "references"
}
}, {
"range": {
"start": { "line": 5, "character": 2 },
"end": { "line": 5, "character": 3 }
},
"data": {
"specifier": "file:///a/file.ts",
"source": "references"
}
}, {
"range": {
"start": { "line": 10, "character": 10 },
@ -4310,6 +4399,15 @@ fn lsp_nav_tree_updates() {
"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"
}
}, {
"range": {
"start": { "line": 4, "character": 6 },
@ -4319,6 +4417,15 @@ fn lsp_nav_tree_updates() {
"specifier": "file:///a/file.ts",
"source": "references"
}
}, {
"range": {
"start": { "line": 5, "character": 2 },
"end": { "line": 5, "character": 3 }
},
"data": {
"specifier": "file:///a/file.ts",
"source": "references"
}
}])
);
client.shutdown();

View file

@ -707,8 +707,9 @@ impl LspClient {
"cache": null,
"certificateStores": null,
"codeLens": {
"implementations": true,
"references": true,
"implementations": false,
"references": false,
"referencesAllFunctions": false,
"test": true,
},
"config": null,