summaryrefslogtreecommitdiff
path: root/cli/lsp/analysis.rs
diff options
context:
space:
mode:
authorKitson Kelly <me@kitsonkelly.com>2021-05-12 00:43:00 +1000
committerGitHub <noreply@github.com>2021-05-11 10:43:00 -0400
commit41a3b17de44684365ddad9ba0ad9d9c488d3b065 (patch)
tree8914e308dd75bc06b255cb52e837197bd190dbd2 /cli/lsp/analysis.rs
parent46f0ac59e0cfa2a90d3e7342f890b5090bdc3f90 (diff)
fix(lsp): remove code_action/diagnostics deadlock (#10555)
Landed without test to meet 1.10.0 deadline. See #10587.
Diffstat (limited to 'cli/lsp/analysis.rs')
-rw-r--r--cli/lsp/analysis.rs39
1 files changed, 18 insertions, 21 deletions
diff --git a/cli/lsp/analysis.rs b/cli/lsp/analysis.rs
index fd848c564..19ee60d4c 100644
--- a/cli/lsp/analysis.rs
+++ b/cli/lsp/analysis.rs
@@ -75,6 +75,24 @@ pub struct Reference {
range: Range,
}
+impl Reference {
+ pub fn to_diagnostic(&self) -> lsp::Diagnostic {
+ match &self.category {
+ Category::Lint { message, code, .. } => lsp::Diagnostic {
+ range: self.range,
+ severity: Some(lsp::DiagnosticSeverity::Warning),
+ code: Some(lsp::NumberOrString::String(code.to_string())),
+ code_description: None,
+ source: Some("deno-lint".to_string()),
+ message: message.to_string(),
+ related_information: None,
+ tags: None, // we should tag unused code
+ data: None,
+ },
+ }
+ }
+}
+
fn as_lsp_range(range: &deno_lint::diagnostic::Range) -> Range {
Range {
start: Position {
@@ -116,27 +134,6 @@ pub fn get_lint_references(
)
}
-pub fn references_to_diagnostics(
- references: Vec<Reference>,
-) -> Vec<lsp::Diagnostic> {
- references
- .into_iter()
- .map(|r| match r.category {
- Category::Lint { message, code, .. } => lsp::Diagnostic {
- range: r.range,
- severity: Some(lsp::DiagnosticSeverity::Warning),
- code: Some(lsp::NumberOrString::String(code)),
- code_description: None,
- source: Some("deno-lint".to_string()),
- message,
- related_information: None,
- tags: None, // we should tag unused code
- data: None,
- },
- })
- .collect()
-}
-
#[derive(Debug, Default, Clone, PartialEq, Eq)]
pub struct Dependency {
pub is_dynamic: bool,