Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cli/lsp/code_lens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,7 @@ pub fn collect_tsc(
));
}
tsc::ScriptElementKind::LocalFunctionElement
| tsc::ScriptElementKind::MemberFunctionElement
| tsc::ScriptElementKind::MemberGetAccessorElement
| tsc::ScriptElementKind::MemberSetAccessorElement
| tsc::ScriptElementKind::ConstructorImplementationElement
Expand Down
111 changes: 109 additions & 2 deletions tests/integration/lsp_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -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 },
Expand All @@ -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 },
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -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 },
Expand All @@ -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 },
Expand Down Expand Up @@ -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 },
Expand All @@ -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();
Expand Down
5 changes: 3 additions & 2 deletions tests/util/server/src/lsp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down