summaryrefslogtreecommitdiff
path: root/cli/lsp/diagnostics.rs
diff options
context:
space:
mode:
authorKitson Kelly <me@kitsonkelly.com>2022-02-02 13:04:26 +1100
committerGitHub <noreply@github.com>2022-02-02 13:04:26 +1100
commit26f5c223df26962f19ccc957d0507facc09c55c5 (patch)
tree2d12e824acefba3e35d8a117693a7b4a7f210cf3 /cli/lsp/diagnostics.rs
parent8176a4d1663529fb8aeebf7734c4994fa1d583f4 (diff)
fix(lsp): properly display x-deno-warning with redirects (#13554)
Fixes: #13472
Diffstat (limited to 'cli/lsp/diagnostics.rs')
-rw-r--r--cli/lsp/diagnostics.rs14
1 files changed, 11 insertions, 3 deletions
diff --git a/cli/lsp/diagnostics.rs b/cli/lsp/diagnostics.rs
index 62b89e526..4f7e50725 100644
--- a/cli/lsp/diagnostics.rs
+++ b/cli/lsp/diagnostics.rs
@@ -1,6 +1,7 @@
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
use super::analysis;
+use super::cache;
use super::client::Client;
use super::config::ConfigSnapshot;
use super::documents;
@@ -571,6 +572,7 @@ fn resolution_error_as_code(
fn diagnose_dependency(
diagnostics: &mut Vec<lsp::Diagnostic>,
documents: &Documents,
+ cache_metadata: &cache::CacheMetadata,
resolved: &deno_graph::Resolved,
is_dynamic: bool,
maybe_assert_type: Option<&str>,
@@ -579,8 +581,10 @@ fn diagnose_dependency(
Resolved::Ok {
specifier, range, ..
} => {
- if let Some(doc) = documents.get(specifier) {
- if let Some(message) = doc.maybe_warning() {
+ if let Some(metadata) = cache_metadata.get(specifier) {
+ if let Some(message) =
+ metadata.get(&cache::MetadataKey::Warning).cloned()
+ {
diagnostics.push(lsp::Diagnostic {
range: documents::to_lsp_range(range),
severity: Some(lsp::DiagnosticSeverity::WARNING),
@@ -588,8 +592,10 @@ fn diagnose_dependency(
source: Some("deno".to_string()),
message,
..Default::default()
- })
+ });
}
+ }
+ if let Some(doc) = documents.get(specifier) {
if doc.media_type() == MediaType::Json {
match maybe_assert_type {
// The module has the correct assertion type, no diagnostic
@@ -667,6 +673,7 @@ async fn generate_deps_diagnostics(
diagnose_dependency(
&mut diagnostics,
&snapshot.documents,
+ &snapshot.cache_metadata,
&dependency.maybe_code,
dependency.is_dynamic,
dependency.maybe_assert_type.as_deref(),
@@ -674,6 +681,7 @@ async fn generate_deps_diagnostics(
diagnose_dependency(
&mut diagnostics,
&snapshot.documents,
+ &snapshot.cache_metadata,
&dependency.maybe_type,
dependency.is_dynamic,
dependency.maybe_assert_type.as_deref(),