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:
parent
ccbaedb138
commit
09b79463d7
5 changed files with 95 additions and 0 deletions
|
@ -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![
|
||||
|
|
12
cli/tests/lsp/did_open_notification_asset.json
Normal file
12
cli/tests/lsp/did_open_notification_asset.json
Normal 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"
|
||||
}
|
||||
}
|
||||
}
|
14
cli/tests/lsp/hover_request_asset_01.json
Normal file
14
cli/tests/lsp/hover_request_asset_01.json
Normal 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
|
||||
}
|
||||
}
|
||||
}
|
14
cli/tests/lsp/hover_request_asset_02.json
Normal file
14
cli/tests/lsp/hover_request_asset_02.json
Normal 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
|
||||
}
|
||||
}
|
||||
}
|
10
cli/tests/lsp/virtual_text_document_request.json
Normal file
10
cli/tests/lsp/virtual_text_document_request.json
Normal file
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"jsonrpc": "2.0",
|
||||
"id": 2,
|
||||
"method": "deno/virtualTextDocument",
|
||||
"params": {
|
||||
"textDocument": {
|
||||
"uri": "deno:/asset//lib.es2015.symbol.wellknown.d.ts"
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue