diff options
Diffstat (limited to 'cli/lsp/analysis.rs')
-rw-r--r-- | cli/lsp/analysis.rs | 39 |
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, |