From dcb4ffb93a380710c32cc212b937ea38db5ceacc Mon Sep 17 00:00:00 2001 From: David Sherret Date: Fri, 25 Nov 2022 18:29:48 -0500 Subject: refactor: move dts files, diagnostics.rs, and tsc.rs to tsc folder (#16820) --- cli/lsp/diagnostics.rs | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) (limited to 'cli/lsp') diff --git a/cli/lsp/diagnostics.rs b/cli/lsp/diagnostics.rs index aac6e5862..58156bad2 100644 --- a/cli/lsp/diagnostics.rs +++ b/cli/lsp/diagnostics.rs @@ -13,7 +13,6 @@ use super::tsc; use super::tsc::TsServer; use crate::args::LintConfig; -use crate::diagnostics; use crate::npm::NpmPackageReference; use deno_ast::MediaType; @@ -43,7 +42,7 @@ pub type DiagnosticRecord = pub type DiagnosticVec = Vec; type DiagnosticMap = HashMap, Vec)>; -type TsDiagnosticsMap = HashMap>; +type TsDiagnosticsMap = HashMap>; type DiagnosticsByVersionMap = HashMap, Vec>; #[derive(Clone)] @@ -335,25 +334,25 @@ impl DiagnosticsServer { } } -impl<'a> From<&'a diagnostics::DiagnosticCategory> for lsp::DiagnosticSeverity { - fn from(category: &'a diagnostics::DiagnosticCategory) -> Self { +impl<'a> From<&'a crate::tsc::DiagnosticCategory> for lsp::DiagnosticSeverity { + fn from(category: &'a crate::tsc::DiagnosticCategory) -> Self { match category { - diagnostics::DiagnosticCategory::Error => lsp::DiagnosticSeverity::ERROR, - diagnostics::DiagnosticCategory::Warning => { + crate::tsc::DiagnosticCategory::Error => lsp::DiagnosticSeverity::ERROR, + crate::tsc::DiagnosticCategory::Warning => { lsp::DiagnosticSeverity::WARNING } - diagnostics::DiagnosticCategory::Suggestion => { + crate::tsc::DiagnosticCategory::Suggestion => { lsp::DiagnosticSeverity::HINT } - diagnostics::DiagnosticCategory::Message => { + crate::tsc::DiagnosticCategory::Message => { lsp::DiagnosticSeverity::INFORMATION } } } } -impl<'a> From<&'a diagnostics::Position> for lsp::Position { - fn from(pos: &'a diagnostics::Position) -> Self { +impl<'a> From<&'a crate::tsc::Position> for lsp::Position { + fn from(pos: &'a crate::tsc::Position) -> Self { Self { line: pos.line as u32, character: pos.character as u32, @@ -361,7 +360,7 @@ impl<'a> From<&'a diagnostics::Position> for lsp::Position { } } -fn get_diagnostic_message(diagnostic: &diagnostics::Diagnostic) -> String { +fn get_diagnostic_message(diagnostic: &crate::tsc::Diagnostic) -> String { if let Some(message) = diagnostic.message_text.clone() { message } else if let Some(message_chain) = diagnostic.message_chain.clone() { @@ -372,8 +371,8 @@ fn get_diagnostic_message(diagnostic: &diagnostics::Diagnostic) -> String { } fn to_lsp_range( - start: &diagnostics::Position, - end: &diagnostics::Position, + start: &crate::tsc::Position, + end: &crate::tsc::Position, ) -> lsp::Range { lsp::Range { start: start.into(), @@ -382,7 +381,7 @@ fn to_lsp_range( } fn to_lsp_related_information( - related_information: &Option>, + related_information: &Option>, ) -> Option> { related_information.as_ref().map(|related| { related @@ -408,7 +407,7 @@ fn to_lsp_related_information( } fn ts_json_to_diagnostics( - diagnostics: Vec, + diagnostics: Vec, ) -> Vec { diagnostics .iter() -- cgit v1.2.3