From 9fdf984958901a6bf16772c2c88b3163f044b390 Mon Sep 17 00:00:00 2001 From: Veetaha Date: Thu, 6 Feb 2020 02:33:18 +0200 Subject: ra_syntax: reshape SyntaxError for the sake of removing redundancy --- crates/ra_ide/src/diagnostics.rs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'crates/ra_ide/src') diff --git a/crates/ra_ide/src/diagnostics.rs b/crates/ra_ide/src/diagnostics.rs index 22bd49723..97af98458 100644 --- a/crates/ra_ide/src/diagnostics.rs +++ b/crates/ra_ide/src/diagnostics.rs @@ -10,7 +10,7 @@ use ra_prof::profile; use ra_syntax::{ algo, ast::{self, make, AstNode}, - Location, SyntaxNode, TextRange, T, + SyntaxNode, TextRange, T, }; use ra_text_edit::{TextEdit, TextEditBuilder}; @@ -29,7 +29,7 @@ pub(crate) fn diagnostics(db: &RootDatabase, file_id: FileId) -> Vec let mut res = Vec::new(); res.extend(parse.errors().iter().map(|err| Diagnostic { - range: location_to_range(err.location()), + range: *err.range(), message: format!("Syntax Error: {}", err), severity: Severity::Error, fix: None, @@ -116,12 +116,6 @@ pub(crate) fn diagnostics(db: &RootDatabase, file_id: FileId) -> Vec drop(sink); res.into_inner() } -fn location_to_range(location: Location) -> TextRange { - match location { - Location::Offset(offset) => TextRange::offset_len(offset, 1.into()), - Location::Range(range) => range, - } -} fn check_unnecessary_braces_in_use_statement( acc: &mut Vec, -- cgit v1.2.3