diff options
author | Kitson Kelly <me@kitsonkelly.com> | 2021-11-18 13:05:20 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-18 13:05:20 +1100 |
commit | 14f83da2210dce53b663581c22d39c98fac1d2f6 (patch) | |
tree | 96605c5056b649a212eb62ea59997182b1dcdf91 | |
parent | 77c4c249ba188c516aecac92fee96c353eb5b087 (diff) |
fix(lsp): tag deprecated diagnostics properly (#12801)
-rw-r--r-- | cli/lsp/diagnostics.rs | 7 | ||||
-rw-r--r-- | cli/tests/integration/lsp_tests.rs | 58 |
2 files changed, 62 insertions, 3 deletions
diff --git a/cli/lsp/diagnostics.rs b/cli/lsp/diagnostics.rs index ddc18f18f..4836cff99 100644 --- a/cli/lsp/diagnostics.rs +++ b/cli/lsp/diagnostics.rs @@ -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, diff --git a/cli/tests/integration/lsp_tests.rs b/cli/tests/integration/lsp_tests.rs index bf9258925..c22bb3bdb 100644 --- a/cli/tests/integration/lsp_tests.rs +++ b/cli/tests/integration/lsp_tests.rs @@ -3015,6 +3015,64 @@ fn lsp_diagnostics_warn() { } #[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"); client |