aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdolfo OchagavĂ­a <[email protected]>2018-10-10 15:59:46 +0100
committerAdolfo OchagavĂ­a <[email protected]>2018-10-10 15:59:46 +0100
commitedd162bda8be065d3e0fc0a70052ce32eeb82553 (patch)
tree0e01cb44e0622c16aaef7c939d319888b68a7d46
parent26d34cc4439174af45d493a14c41631121fa2ccd (diff)
Report errors only once
-rw-r--r--crates/ra_editor/src/lib.rs17
1 files changed, 3 insertions, 14 deletions
diff --git a/crates/ra_editor/src/lib.rs b/crates/ra_editor/src/lib.rs
index 15aaac172..906ee11fe 100644
--- a/crates/ra_editor/src/lib.rs
+++ b/crates/ra_editor/src/lib.rs
@@ -107,21 +107,10 @@ pub fn highlight(file: &File) -> Vec<HighlightedRange> {
107} 107}
108 108
109pub fn diagnostics(file: &File) -> Vec<Diagnostic> { 109pub fn diagnostics(file: &File) -> Vec<Diagnostic> {
110 let mut res = Vec::new(); 110 file.errors().into_iter().map(|err| Diagnostic {
111
112 for node in file.syntax().descendants() {
113 if node.kind() == ERROR {
114 res.push(Diagnostic {
115 range: node.range(),
116 msg: "Syntax Error".to_string(),
117 });
118 }
119 }
120 res.extend(file.errors().into_iter().map(|err| Diagnostic {
121 range: TextRange::offset_len(err.offset, 1.into()), 111 range: TextRange::offset_len(err.offset, 1.into()),
122 msg: err.msg, 112 msg: "Syntax Error: ".to_string() + &err.msg,
123 })); 113 }).collect()
124 res
125} 114}
126 115
127pub fn syntax_tree(file: &File) -> String { 116pub fn syntax_tree(file: &File) -> String {