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

feat(lsp): add asset cache regression test

When we migrated away from all the locks, there was a regression that
was not caught immediately. The tsc::get_asset() would attempt to modify
the snapshot, but the problem was that the snapshot was a .clone() of
the inner language server's assets, which meant that modifications to
that where lost. When we then attempted to do a hover on those assets,
the inner language servers assets didn't have the retrieved asset, and
therefore would throw an error.
This commit is contained in:
Kitson Kelly 2021-02-06 13:39:01 +01:00 committed by Ben Noordhuis
parent ccbaedb138
commit 09b79463d7
5 changed files with 95 additions and 0 deletions

View file

@ -1934,6 +1934,51 @@ mod tests {
harness.run().await;
}
#[tokio::test]
async fn test_hover_asset() {
let mut harness = LspTestHarness::new(vec![
("initialize_request.json", LspResponse::RequestAny),
("initialized_notification.json", LspResponse::None),
("did_open_notification_asset.json", LspResponse::None),
("hover_request_asset_01.json", LspResponse::RequestAny),
(
"virtual_text_document_request.json",
LspResponse::RequestAny,
),
(
"hover_request_asset_02.json",
LspResponse::Request(
4,
json!({
"contents": [
{
"language": "typescript",
"value": "interface Date",
},
"Enables basic storage and retrieval of dates and times."
],
"range": {
"start": {
"line": 109,
"character": 10,
},
"end": {
"line": 109,
"character": 14,
}
}
}),
),
),
(
"shutdown_request.json",
LspResponse::Request(3, json!(null)),
),
("exit_notification.json", LspResponse::None),
]);
harness.run().await;
}
#[tokio::test]
async fn test_hover_disabled() {
let mut harness = LspTestHarness::new(vec![

View file

@ -0,0 +1,12 @@
{
"jsonrpc": "2.0",
"method": "textDocument/didOpen",
"params": {
"textDocument": {
"uri": "file:///a/file.ts",
"languageId": "typescript",
"version": 1,
"text": "console.log(Date.now());\n"
}
}
}

View file

@ -0,0 +1,14 @@
{
"jsonrpc": "2.0",
"id": 4,
"method": "textDocument/hover",
"params": {
"textDocument": {
"uri": "file:///a/file.ts"
},
"position": {
"line": 0,
"character": 12
}
}
}

View file

@ -0,0 +1,14 @@
{
"jsonrpc": "2.0",
"id": 4,
"method": "textDocument/hover",
"params": {
"textDocument": {
"uri": "deno:/asset//lib.es2015.symbol.wellknown.d.ts"
},
"position": {
"line": 109,
"character": 13
}
}
}

View file

@ -0,0 +1,10 @@
{
"jsonrpc": "2.0",
"id": 2,
"method": "deno/virtualTextDocument",
"params": {
"textDocument": {
"uri": "deno:/asset//lib.es2015.symbol.wellknown.d.ts"
}
}
}