diff options
author | Veetaha <[email protected]> | 2020-02-06 00:33:18 +0000 |
---|---|---|
committer | Veetaha <[email protected]> | 2020-02-17 20:24:33 +0000 |
commit | 9fdf984958901a6bf16772c2c88b3163f044b390 (patch) | |
tree | b3f86c533c6a9a86a9183cb117e23efd382c045e /crates/ra_ide/src | |
parent | 9053003e3b298b38f6029b860efc5baed1996385 (diff) |
ra_syntax: reshape SyntaxError for the sake of removing redundancy
Diffstat (limited to 'crates/ra_ide/src')
-rw-r--r-- | crates/ra_ide/src/diagnostics.rs | 10 |
1 files changed, 2 insertions, 8 deletions
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; | |||
10 | use ra_syntax::{ | 10 | use ra_syntax::{ |
11 | algo, | 11 | algo, |
12 | ast::{self, make, AstNode}, | 12 | ast::{self, make, AstNode}, |
13 | Location, SyntaxNode, TextRange, T, | 13 | SyntaxNode, TextRange, T, |
14 | }; | 14 | }; |
15 | use ra_text_edit::{TextEdit, TextEditBuilder}; | 15 | use ra_text_edit::{TextEdit, TextEditBuilder}; |
16 | 16 | ||
@@ -29,7 +29,7 @@ pub(crate) fn diagnostics(db: &RootDatabase, file_id: FileId) -> Vec<Diagnostic> | |||
29 | let mut res = Vec::new(); | 29 | let mut res = Vec::new(); |
30 | 30 | ||
31 | res.extend(parse.errors().iter().map(|err| Diagnostic { | 31 | res.extend(parse.errors().iter().map(|err| Diagnostic { |
32 | range: location_to_range(err.location()), | 32 | range: *err.range(), |
33 | message: format!("Syntax Error: {}", err), | 33 | message: format!("Syntax Error: {}", err), |
34 | severity: Severity::Error, | 34 | severity: Severity::Error, |
35 | fix: None, | 35 | fix: None, |
@@ -116,12 +116,6 @@ pub(crate) fn diagnostics(db: &RootDatabase, file_id: FileId) -> Vec<Diagnostic> | |||
116 | drop(sink); | 116 | drop(sink); |
117 | res.into_inner() | 117 | res.into_inner() |
118 | } | 118 | } |
119 | fn location_to_range(location: Location) -> TextRange { | ||
120 | match location { | ||
121 | Location::Offset(offset) => TextRange::offset_len(offset, 1.into()), | ||
122 | Location::Range(range) => range, | ||
123 | } | ||
124 | } | ||
125 | 119 | ||
126 | fn check_unnecessary_braces_in_use_statement( | 120 | fn check_unnecessary_braces_in_use_statement( |
127 | acc: &mut Vec<Diagnostic>, | 121 | acc: &mut Vec<Diagnostic>, |