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

fix(lsp): tag deprecated diagnostics properly (#12801)

This commit is contained in:
Kitson Kelly 2021-11-18 13:05:20 +11:00 committed by GitHub
parent 77c4c249ba
commit 14f83da221
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 62 additions and 3 deletions

View file

@ -285,9 +285,10 @@ fn ts_json_to_diagnostics(
),
tags: match d.code {
// These are codes that indicate the variable is unused.
2695 | 6133 | 6138 | 6192 | 6196 | 6198 | 6199 | 7027 | 7028 => {
Some(vec![lsp::DiagnosticTag::Unnecessary])
}
2695 | 6133 | 6138 | 6192 | 6196 | 6198 | 6199 | 6205 | 7027
| 7028 => Some(vec![lsp::DiagnosticTag::Unnecessary]),
// These are codes that indicated the variable is deprecated.
2789 | 6385 | 6387 => Some(vec![lsp::DiagnosticTag::Deprecated]),
_ => None,
},
data: None,

View file

@ -3014,6 +3014,64 @@ fn lsp_diagnostics_warn() {
shutdown(&mut client);
}
#[test]
fn lsp_diagnostics_deprecated() {
let mut client = init("initialize_params.json");
let diagnostics = did_open(
&mut client,
json!({
"textDocument": {
"uri": "file:///a/file.ts",
"languageId": "typescript",
"version": 1,
"text": "/** @deprecated */\nexport const a = \"a\";\n\na;\n",
},
}),
);
assert_eq!(
json!(diagnostics),
json!([
{
"uri": "file:///a/file.ts",
"diagnostics": [],
"version": 1
},
{
"uri": "file:///a/file.ts",
"diagnostics": [],
"version": 1
},
{
"uri": "file:///a/file.ts",
"diagnostics": [
{
"range": {
"start": {
"line": 3,
"character": 0
},
"end": {
"line": 3,
"character": 1
}
},
"severity": 4,
"code": 6385,
"source": "deno-ts",
"message": "'a' is deprecated.",
"relatedInformation": [],
"tags": [
2
]
}
],
"version": 1
}
])
);
shutdown(&mut client);
}
#[test]
fn lsp_diagnostics_deno_types() {
let mut client = init("initialize_params.json");