1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-25 15:29:32 -05:00

fix(#10695): deps diagnostics include data property (#10696)

Fixes #10695
This commit is contained in:
Kitson Kelly 2021-05-19 22:28:23 +10:00 committed by GitHub
parent 3af44a26eb
commit 91decbfabf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 39 additions and 5 deletions

View file

@ -11,6 +11,7 @@ use crate::tokio_util::create_basic_runtime;
use deno_core::error::anyhow;
use deno_core::error::AnyError;
use deno_core::resolve_url;
use deno_core::serde_json::json;
use deno_core::ModuleSpecifier;
use log::error;
use lspower::lsp;
@ -446,6 +447,7 @@ async fn generate_deps_diagnostics(
code,
source: Some("deno".to_string()),
message,
data: Some(json!({ "specifier": specifier })),
..Default::default()
});
} else if sources.contains_key(&specifier) {

View file

@ -1362,17 +1362,24 @@ fn lsp_code_actions() {
#[test]
fn lsp_code_actions_deno_cache() {
let mut client = init("initialize_params.json");
did_open(
&mut client,
json!({
client
.write_notification("textDocument/didOpen", json!({
"textDocument": {
"uri": "file:///a/file.ts",
"languageId": "typescript",
"version": 1,
"text": "import * as a from \"https://deno.land/x/a/mod.ts\";\n\nconsole.log(a);\n"
}
}),
);
}))
.unwrap();
let (method, _) = client.read_notification::<Value>().unwrap();
assert_eq!(method, "textDocument/publishDiagnostics");
let (method, _) = client.read_notification::<Value>().unwrap();
assert_eq!(method, "textDocument/publishDiagnostics");
let (method, params) = client.read_notification().unwrap();
assert_eq!(method, "textDocument/publishDiagnostics");
assert_eq!(params, Some(load_fixture("diagnostics_deno_deps.json")));
let (maybe_res, maybe_err) = client
.write_request(
"textDocument/codeAction",

View file

@ -0,0 +1,25 @@
{
"uri": "file:///a/file.ts",
"diagnostics": [
{
"range": {
"start": {
"line": 0,
"character": 19
},
"end": {
"line": 0,
"character": 49
}
},
"severity": 1,
"code": "no-cache",
"source": "deno",
"message": "Uncached or missing remote URL: \"https://deno.land/x/a/mod.ts\".",
"data": {
"specifier": "https://deno.land/x/a/mod.ts"
}
}
],
"version": 1
}