summaryrefslogtreecommitdiff
path: root/tests/integration
diff options
context:
space:
mode:
authorNayeem Rahman <nayeemrmn99@gmail.com>2024-10-21 17:15:52 +0100
committerGitHub <noreply@github.com>2024-10-21 17:15:52 +0100
commit9fe2bf42dc584779cc43f0ec15a5a3d6dddca283 (patch)
treef537a20aac656ef5064a894b5c340f44da5719aa /tests/integration
parentafb33b3c2597c9ec943f71218b236486fbc86e23 (diff)
feat(lsp): interactive inlay hints (#26382)
Diffstat (limited to 'tests/integration')
-rw-r--r--tests/integration/lsp_tests.rs182
1 files changed, 142 insertions, 40 deletions
diff --git a/tests/integration/lsp_tests.rs b/tests/integration/lsp_tests.rs
index 85e02041e..0b7c5dd3f 100644
--- a/tests/integration/lsp_tests.rs
+++ b/tests/integration/lsp_tests.rs
@@ -1827,15 +1827,41 @@ fn lsp_hover_disabled() {
fn lsp_inlay_hints() {
let context = TestContextBuilder::new().use_temp_cwd().build();
let mut client = context.new_lsp_command().build();
- client.initialize(|builder| {
- builder.enable_inlay_hints();
- });
+ client.initialize_default();
+ client.change_configuration(json!({
+ "deno": {
+ "enable": true,
+ },
+ "typescript": {
+ "inlayHints": {
+ "parameterNames": {
+ "enabled": "all",
+ },
+ "parameterTypes": {
+ "enabled": true,
+ },
+ "variableTypes": {
+ "enabled": true,
+ },
+ "propertyDeclarationTypes": {
+ "enabled": true,
+ },
+ "functionLikeReturnTypes": {
+ "enabled": true,
+ },
+ "enumMemberValues": {
+ "enabled": true,
+ },
+ },
+ },
+ }));
client.did_open(json!({
"textDocument": {
"uri": "file:///a/file.ts",
"languageId": "typescript",
"version": 1,
- "text": r#"function a(b: string) {
+ "text": r#"
+ function a(b: string) {
return b;
}
@@ -1854,8 +1880,19 @@ fn lsp_inlay_hints() {
}
["a"].map((v) => v + v);
- "#
- }
+
+ interface Bar {
+ someField: string;
+ }
+ function getBar(): Bar {
+ return { someField: "foo" };
+ }
+ // This shouldn't have a type hint because the variable name makes it
+ // redundant.
+ const bar = getBar();
+ const someValue = getBar();
+ "#,
+ },
}));
let res = client.write_request(
"textDocument/inlayHint",
@@ -1864,65 +1901,130 @@ fn lsp_inlay_hints() {
"uri": "file:///a/file.ts",
},
"range": {
- "start": { "line": 0, "character": 0 },
- "end": { "line": 19, "character": 0, }
- }
+ "start": { "line": 1, "character": 0 },
+ "end": { "line": 31, "character": 0, },
+ },
}),
);
assert_eq!(
res,
json!([
{
- "position": { "line": 0, "character": 21 },
- "label": ": string",
+ "position": { "line": 1, "character": 29 },
+ "label": [{ "value": ": " }, { "value": "string" }],
"kind": 1,
- "paddingLeft": true
+ "paddingLeft": true,
}, {
- "position": { "line": 4, "character": 10 },
- "label": "b:",
+ "position": { "line": 5, "character": 10 },
+ "label": [
+ {
+ "value": "b",
+ "location": {
+ "uri": "file:///a/file.ts",
+ "range": {
+ "start": { "line": 1, "character": 19 },
+ "end": { "line": 1, "character": 20 },
+ },
+ },
+ },
+ { "value": ":" },
+ ],
"kind": 2,
- "paddingRight": true
+ "paddingRight": true,
}, {
- "position": { "line": 7, "character": 11 },
+ "position": { "line": 8, "character": 11 },
"label": "= 0",
- "paddingLeft": true
+ "paddingLeft": true,
}, {
- "position": { "line": 10, "character": 17 },
- "label": "string:",
+ "position": { "line": 11, "character": 17 },
+ "label": [
+ {
+ "value": "string",
+ "location": {
+ "uri": "deno:/asset/lib.es5.d.ts",
+ "range": {
+ "start": { "line": 41, "character": 26 },
+ "end": { "line": 41, "character": 32 },
+ },
+ },
+ },
+ { "value": ":" },
+ ],
"kind": 2,
- "paddingRight": true
+ "paddingRight": true,
}, {
- "position": { "line": 10, "character": 24 },
- "label": "radix:",
+ "position": { "line": 11, "character": 24 },
+ "label": [
+ {
+ "value": "radix",
+ "location": {
+ "uri": "deno:/asset/lib.es5.d.ts",
+ "range": {
+ "start": { "line": 41, "character": 42 },
+ "end": { "line": 41, "character": 47 },
+ },
+ },
+ },
+ { "value": ":" },
+ ],
"kind": 2,
- "paddingRight": true
+ "paddingRight": true,
}, {
- "position": { "line": 12, "character": 15 },
- "label": ": number",
+ "position": { "line": 13, "character": 15 },
+ "label": [{ "value": ": " }, { "value": "number" }],
"kind": 1,
- "paddingLeft": true
+ "paddingLeft": true,
}, {
- "position": { "line": 15, "character": 11 },
- "label": ": number",
+ "position": { "line": 16, "character": 11 },
+ "label": [{ "value": ": " }, { "value": "number" }],
"kind": 1,
- "paddingLeft": true
+ "paddingLeft": true,
}, {
- "position": { "line": 18, "character": 18 },
- "label": "callbackfn:",
+ "position": { "line": 19, "character": 18 },
+ "label": [
+ {
+ "value": "callbackfn",
+ "location": {
+ "uri": "deno:/asset/lib.es5.d.ts",
+ "range": {
+ "start": { "line": 1462, "character": 11 },
+ "end": { "line": 1462, "character": 21 },
+ },
+ },
+ },
+ { "value": ":" },
+ ],
"kind": 2,
- "paddingRight": true
+ "paddingRight": true,
}, {
- "position": { "line": 18, "character": 20 },
- "label": ": string",
+ "position": { "line": 19, "character": 20 },
+ "label": [{ "value": ": " }, { "value": "string" }],
"kind": 1,
- "paddingLeft": true
+ "paddingLeft": true,
}, {
- "position": { "line": 18, "character": 21 },
- "label": ": string",
+ "position": { "line": 19, "character": 21 },
+ "label": [{ "value": ": " }, { "value": "string" }],
"kind": 1,
- "paddingLeft": true
- }
- ])
+ "paddingLeft": true,
+ }, {
+ "position": { "line": 30, "character": 23 },
+ "label": [
+ { "value": ": " },
+ {
+ "value": "Bar",
+ "location": {
+ "uri": "file:///a/file.ts",
+ "range": {
+ "start": { "line": 21, "character": 18 },
+ "end": { "line": 21, "character": 21 },
+ },
+ },
+ },
+ ],
+ "kind": 1,
+ "paddingLeft": true,
+ },
+ ]),
);
client.shutdown();
}