aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_editor/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_editor/src/lib.rs')
-rw-r--r--crates/ra_editor/src/lib.rs12
1 files changed, 10 insertions, 2 deletions
diff --git a/crates/ra_editor/src/lib.rs b/crates/ra_editor/src/lib.rs
index 3186eaf1a..f92181b86 100644
--- a/crates/ra_editor/src/lib.rs
+++ b/crates/ra_editor/src/lib.rs
@@ -31,6 +31,7 @@ use ra_syntax::{
31 algo::find_leaf_at_offset, 31 algo::find_leaf_at_offset,
32 ast::{self, AstNode, NameOwner}, 32 ast::{self, AstNode, NameOwner},
33 File, 33 File,
34 Location,
34 SyntaxKind::{self, *}, 35 SyntaxKind::{self, *},
35 SyntaxNodeRef, TextRange, TextUnit, 36 SyntaxNodeRef, TextRange, TextUnit,
36}; 37};
@@ -100,11 +101,18 @@ pub fn highlight(file: &File) -> Vec<HighlightedRange> {
100} 101}
101 102
102pub fn diagnostics(file: &File) -> Vec<Diagnostic> { 103pub fn diagnostics(file: &File) -> Vec<Diagnostic> {
104 fn location_to_range(location: Location) -> TextRange {
105 match location {
106 Location::Offset(offset) => TextRange::offset_len(offset, 1.into()),
107 Location::Range(range) => range,
108 }
109 }
110
103 file.errors() 111 file.errors()
104 .into_iter() 112 .into_iter()
105 .map(|err| Diagnostic { 113 .map(|err| Diagnostic {
106 range: TextRange::offset_len(err.offset, 1.into()), 114 range: location_to_range(err.location()),
107 msg: "Syntax Error: ".to_string() + &err.msg, 115 msg: format!("Syntax Error: {}", err),
108 }) 116 })
109 .collect() 117 .collect()
110} 118}