aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_editor
diff options
context:
space:
mode:
authorAdolfo OchagavĂ­a <[email protected]>2018-11-05 17:38:34 +0000
committerAdolfo OchagavĂ­a <[email protected]>2018-11-05 17:38:34 +0000
commitfda8ddc5fe8a764c0dc91fecb92af1bdf3078485 (patch)
tree1de03cfa42f40bb5ca19956534f53d0b92d271d5 /crates/ra_editor
parent3b42ddae601fbd73f672e82028e04c3abdf1252d (diff)
Introduce Location and make SyntaxError fields private
Diffstat (limited to 'crates/ra_editor')
-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 25124dbe3..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: err.range, 114 range: location_to_range(err.location()),
107 msg: format!("Syntax Error: {}", err.kind), 115 msg: format!("Syntax Error: {}", err),
108 }) 116 })
109 .collect() 117 .collect()
110} 118}