aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-02-18 12:57:26 +0000
committerGitHub <[email protected]>2020-02-18 12:57:26 +0000
commitc447fe9bc06006a7080da782cf67d739c91b534c (patch)
tree45cbc9578b24437da3eedc6a234784be22b1f38c /crates/ra_ide/src
parent742459c8fe08e359ae380e3e1dc0d059c0b4f871 (diff)
parent053ccf4121797e4e559e3225d46d3f23cb1ad70b (diff)
Merge #3026
3026: ra_syntax: reshape SyntaxError for the sake of removing redundancy r=matklad a=Veetaha Followup of #2911, also puts some crosses to the todo list of #223. **AHTUNG!** A big part of the diff of this PR are test data files changes. Simplified `SyntaxError` that was `SyntaxError { kind: { /* big enum */ }, location: Location }` to `SyntaxError(String, TextRange)`. I am not sure whether the tuple struct here is best fit, I am inclined to add names to the fields, because I already provide getters `SyntaxError::message()`, `SyntaxError::range()`. I also removed `Location` altogether ... This is currently WIP, because the following is not done: - [ ] ~~Add tests to `test_data` dir for unescape errors *// I don't know where to put these errors in particular, because they are out of the scope of the lexer and parser. However, I have an idea in mind that we move all validators we have right now to parsing stage, but this is up to discussion...*~~ **[UPD]** I came to a conclusion that tree validation logic, which unescape errors are a part of, should be rethought of, we currently have no tests and no place to put tests for tree validations. So I'd like to extract potential redesign (maybe move of tree validation to ra_parser) and adding tests for this into a separate task. Co-authored-by: Veetaha <[email protected]> Co-authored-by: Veetaha <[email protected]>
Diffstat (limited to 'crates/ra_ide/src')
-rw-r--r--crates/ra_ide/src/diagnostics.rs10
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..82596c665 100644
--- a/crates/ra_ide/src/diagnostics.rs
+++ b/crates/ra_ide/src/diagnostics.rs
@@ -10,7 +10,7 @@ use ra_prof::profile;
10use ra_syntax::{ 10use 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};
15use ra_text_edit::{TextEdit, TextEditBuilder}; 15use 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}
119fn 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
126fn check_unnecessary_braces_in_use_statement( 120fn check_unnecessary_braces_in_use_statement(
127 acc: &mut Vec<Diagnostic>, 121 acc: &mut Vec<Diagnostic>,