fix(lsp): display module types only dependencies on hover (#12683)

Fixes: #12675
This commit is contained in:
Kitson Kelly 2021-11-08 11:50:48 +11:00 committed by GitHub
parent 91f8bdda2c
commit 182de1452b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 115 additions and 10 deletions

View file

@ -1066,6 +1066,76 @@ fn lsp_hover_dependency() {
);
}
#[test]
fn lsp_hover_typescript_types() {
let _g = http_server();
let mut client = init("initialize_params.json");
did_open(
&mut client,
json!({
"textDocument": {
"uri": "file:///a/file.ts",
"languageId": "typescript",
"version": 1,
"text": "import * as a from \"http://127.0.0.1:4545/xTypeScriptTypes.js\";\n\nconsole.log(a.foo);\n",
}
}),
);
let (maybe_res, maybe_err) = client
.write_request::<_, _, Value>(
"deno/cache",
json!({
"referrer": {
"uri": "file:///a/file.ts",
},
"uris": [
{
"uri": "http://127.0.0.1:4545/xTypeScriptTypes.js",
}
],
}),
)
.unwrap();
assert!(maybe_err.is_none());
assert!(maybe_res.is_some());
let (maybe_res, maybe_err) = client
.write_request::<_, _, Value>(
"textDocument/hover",
json!({
"textDocument": {
"uri": "file:///a/file.ts"
},
"position": {
"line": 0,
"character": 24
}
}),
)
.unwrap();
assert!(maybe_res.is_some());
assert!(maybe_err.is_none());
assert_eq!(
json!(maybe_res.unwrap()),
json!({
"contents": {
"kind": "markdown",
"value": "**Resolved Dependency**\n\n**Code**: http&#8203;://127.0.0.1:4545/xTypeScriptTypes.js\n\n**Types**: http&#8203;://127.0.0.1:4545/xTypeScriptTypes.d.ts\n"
},
"range": {
"start": {
"line": 0,
"character": 19
},
"end": {
"line": 0,
"character": 62
}
}
})
);
shutdown(&mut client);
}
#[test]
fn lsp_call_hierarchy() {
let mut client = init("initialize_params.json");