mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 17:34:47 -05:00
fix(lsp): show reference code lens on methods (#23804)
This commit is contained in:
parent
e39b94f3aa
commit
dda8979cb1
3 changed files with 113 additions and 4 deletions
|
@ -505,6 +505,7 @@ pub fn collect_tsc(
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
tsc::ScriptElementKind::LocalFunctionElement
|
tsc::ScriptElementKind::LocalFunctionElement
|
||||||
|
| tsc::ScriptElementKind::MemberFunctionElement
|
||||||
| tsc::ScriptElementKind::MemberGetAccessorElement
|
| tsc::ScriptElementKind::MemberGetAccessorElement
|
||||||
| tsc::ScriptElementKind::MemberSetAccessorElement
|
| tsc::ScriptElementKind::MemberSetAccessorElement
|
||||||
| tsc::ScriptElementKind::ConstructorImplementationElement
|
| tsc::ScriptElementKind::ConstructorImplementationElement
|
||||||
|
|
|
@ -3509,10 +3509,18 @@ fn lsp_semantic_tokens() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn lsp_code_lens() {
|
fn lsp_code_lens_references() {
|
||||||
let context = TestContextBuilder::new().use_temp_cwd().build();
|
let context = TestContextBuilder::new().use_temp_cwd().build();
|
||||||
let mut client = context.new_lsp_command().build();
|
let mut client = context.new_lsp_command().build();
|
||||||
client.initialize_default();
|
client.initialize_default();
|
||||||
|
client.change_configuration(json!({
|
||||||
|
"deno": {
|
||||||
|
"enable": true,
|
||||||
|
"codeLens": {
|
||||||
|
"references": true,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}));
|
||||||
client.did_open(json!({
|
client.did_open(json!({
|
||||||
"textDocument": {
|
"textDocument": {
|
||||||
"uri": "file:///a/file.ts",
|
"uri": "file:///a/file.ts",
|
||||||
|
@ -3567,6 +3575,24 @@ fn lsp_code_lens() {
|
||||||
"specifier": "file:///a/file.ts",
|
"specifier": "file:///a/file.ts",
|
||||||
"source": "references"
|
"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(
|
let res = client.write_request(
|
||||||
|
@ -3684,10 +3710,19 @@ fn lsp_code_lens() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn lsp_code_lens_impl() {
|
fn lsp_code_lens_implementations() {
|
||||||
let context = TestContextBuilder::new().use_temp_cwd().build();
|
let context = TestContextBuilder::new().use_temp_cwd().build();
|
||||||
let mut client = context.new_lsp_command().build();
|
let mut client = context.new_lsp_command().build();
|
||||||
client.initialize_default();
|
client.initialize_default();
|
||||||
|
client.change_configuration(json!({
|
||||||
|
"deno": {
|
||||||
|
"enable": true,
|
||||||
|
"codeLens": {
|
||||||
|
"implementations": true,
|
||||||
|
"references": true,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}));
|
||||||
client.did_open(
|
client.did_open(
|
||||||
json!({
|
json!({
|
||||||
"textDocument": {
|
"textDocument": {
|
||||||
|
@ -3726,6 +3761,15 @@ fn lsp_code_lens_impl() {
|
||||||
"specifier": "file:///a/file.ts",
|
"specifier": "file:///a/file.ts",
|
||||||
"source": "references"
|
"source": "references"
|
||||||
}
|
}
|
||||||
|
}, {
|
||||||
|
"range": {
|
||||||
|
"start": { "line": 1, "character": 2 },
|
||||||
|
"end": { "line": 1, "character": 3 }
|
||||||
|
},
|
||||||
|
"data": {
|
||||||
|
"specifier": "file:///a/file.ts",
|
||||||
|
"source": "references"
|
||||||
|
}
|
||||||
}, {
|
}, {
|
||||||
"range": {
|
"range": {
|
||||||
"start": { "line": 4, "character": 6 },
|
"start": { "line": 4, "character": 6 },
|
||||||
|
@ -3735,6 +3779,15 @@ fn lsp_code_lens_impl() {
|
||||||
"specifier": "file:///a/file.ts",
|
"specifier": "file:///a/file.ts",
|
||||||
"source": "references"
|
"source": "references"
|
||||||
}
|
}
|
||||||
|
}, {
|
||||||
|
"range": {
|
||||||
|
"start": { "line": 5, "character": 2 },
|
||||||
|
"end": { "line": 5, "character": 3 }
|
||||||
|
},
|
||||||
|
"data": {
|
||||||
|
"specifier": "file:///a/file.ts",
|
||||||
|
"source": "references"
|
||||||
|
}
|
||||||
}, {
|
}, {
|
||||||
"range": {
|
"range": {
|
||||||
"start": { "line": 10, "character": 10 },
|
"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 context = TestContextBuilder::new().use_temp_cwd().build();
|
||||||
let mut client = context.new_lsp_command().build();
|
let mut client = context.new_lsp_command().build();
|
||||||
client.initialize_default();
|
client.initialize_default();
|
||||||
|
client.change_configuration(json!({
|
||||||
|
"deno": {
|
||||||
|
"enable": true,
|
||||||
|
"codeLens": {
|
||||||
|
"implementations": true,
|
||||||
|
"references": true,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}));
|
||||||
client.did_open(json!({
|
client.did_open(json!({
|
||||||
"textDocument": {
|
"textDocument": {
|
||||||
"uri": "file:///a/file.ts",
|
"uri": "file:///a/file.ts",
|
||||||
|
@ -4188,6 +4250,15 @@ fn lsp_nav_tree_updates() {
|
||||||
let context = TestContextBuilder::new().use_temp_cwd().build();
|
let context = TestContextBuilder::new().use_temp_cwd().build();
|
||||||
let mut client = context.new_lsp_command().build();
|
let mut client = context.new_lsp_command().build();
|
||||||
client.initialize_default();
|
client.initialize_default();
|
||||||
|
client.change_configuration(json!({
|
||||||
|
"deno": {
|
||||||
|
"enable": true,
|
||||||
|
"codeLens": {
|
||||||
|
"implementations": true,
|
||||||
|
"references": true,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}));
|
||||||
client.did_open(
|
client.did_open(
|
||||||
json!({
|
json!({
|
||||||
"textDocument": {
|
"textDocument": {
|
||||||
|
@ -4226,6 +4297,15 @@ fn lsp_nav_tree_updates() {
|
||||||
"specifier": "file:///a/file.ts",
|
"specifier": "file:///a/file.ts",
|
||||||
"source": "references"
|
"source": "references"
|
||||||
}
|
}
|
||||||
|
}, {
|
||||||
|
"range": {
|
||||||
|
"start": { "line": 1, "character": 2 },
|
||||||
|
"end": { "line": 1, "character": 3 }
|
||||||
|
},
|
||||||
|
"data": {
|
||||||
|
"specifier": "file:///a/file.ts",
|
||||||
|
"source": "references"
|
||||||
|
}
|
||||||
}, {
|
}, {
|
||||||
"range": {
|
"range": {
|
||||||
"start": { "line": 4, "character": 6 },
|
"start": { "line": 4, "character": 6 },
|
||||||
|
@ -4235,6 +4315,15 @@ fn lsp_nav_tree_updates() {
|
||||||
"specifier": "file:///a/file.ts",
|
"specifier": "file:///a/file.ts",
|
||||||
"source": "references"
|
"source": "references"
|
||||||
}
|
}
|
||||||
|
}, {
|
||||||
|
"range": {
|
||||||
|
"start": { "line": 5, "character": 2 },
|
||||||
|
"end": { "line": 5, "character": 3 }
|
||||||
|
},
|
||||||
|
"data": {
|
||||||
|
"specifier": "file:///a/file.ts",
|
||||||
|
"source": "references"
|
||||||
|
}
|
||||||
}, {
|
}, {
|
||||||
"range": {
|
"range": {
|
||||||
"start": { "line": 10, "character": 10 },
|
"start": { "line": 10, "character": 10 },
|
||||||
|
@ -4310,6 +4399,15 @@ fn lsp_nav_tree_updates() {
|
||||||
"specifier": "file:///a/file.ts",
|
"specifier": "file:///a/file.ts",
|
||||||
"source": "references"
|
"source": "references"
|
||||||
}
|
}
|
||||||
|
}, {
|
||||||
|
"range": {
|
||||||
|
"start": { "line": 1, "character": 2 },
|
||||||
|
"end": { "line": 1, "character": 3 }
|
||||||
|
},
|
||||||
|
"data": {
|
||||||
|
"specifier": "file:///a/file.ts",
|
||||||
|
"source": "references"
|
||||||
|
}
|
||||||
}, {
|
}, {
|
||||||
"range": {
|
"range": {
|
||||||
"start": { "line": 4, "character": 6 },
|
"start": { "line": 4, "character": 6 },
|
||||||
|
@ -4319,6 +4417,15 @@ fn lsp_nav_tree_updates() {
|
||||||
"specifier": "file:///a/file.ts",
|
"specifier": "file:///a/file.ts",
|
||||||
"source": "references"
|
"source": "references"
|
||||||
}
|
}
|
||||||
|
}, {
|
||||||
|
"range": {
|
||||||
|
"start": { "line": 5, "character": 2 },
|
||||||
|
"end": { "line": 5, "character": 3 }
|
||||||
|
},
|
||||||
|
"data": {
|
||||||
|
"specifier": "file:///a/file.ts",
|
||||||
|
"source": "references"
|
||||||
|
}
|
||||||
}])
|
}])
|
||||||
);
|
);
|
||||||
client.shutdown();
|
client.shutdown();
|
||||||
|
|
|
@ -707,8 +707,9 @@ impl LspClient {
|
||||||
"cache": null,
|
"cache": null,
|
||||||
"certificateStores": null,
|
"certificateStores": null,
|
||||||
"codeLens": {
|
"codeLens": {
|
||||||
"implementations": true,
|
"implementations": false,
|
||||||
"references": true,
|
"references": false,
|
||||||
|
"referencesAllFunctions": false,
|
||||||
"test": true,
|
"test": true,
|
||||||
},
|
},
|
||||||
"config": null,
|
"config": null,
|
||||||
|
|
Loading…
Add table
Reference in a new issue