Skip to content

Commit

Permalink
fix(lsp): remove code_action/diagnostics deadlock
Browse files Browse the repository at this point in the history
  • Loading branch information
kitsonk committed May 11, 2021
1 parent 2aa45f8 commit 2ceb69a
Show file tree
Hide file tree
Showing 3 changed files with 355 additions and 422 deletions.
39 changes: 18 additions & 21 deletions cli/lsp/analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down
Loading

0 comments on commit 2ceb69a

Please sign in to comment.