From 3b42ddae601fbd73f672e82028e04c3abdf1252d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adolfo=20Ochagav=C3=ADa?= Date: Sun, 4 Nov 2018 16:45:22 +0100 Subject: Introduce SyntaxErrorKind and TextRange in SyntaxError --- crates/ra_editor/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'crates/ra_editor/src') diff --git a/crates/ra_editor/src/lib.rs b/crates/ra_editor/src/lib.rs index 3186eaf1a..25124dbe3 100644 --- a/crates/ra_editor/src/lib.rs +++ b/crates/ra_editor/src/lib.rs @@ -103,8 +103,8 @@ pub fn diagnostics(file: &File) -> Vec { file.errors() .into_iter() .map(|err| Diagnostic { - range: TextRange::offset_len(err.offset, 1.into()), - msg: "Syntax Error: ".to_string() + &err.msg, + range: err.range, + msg: format!("Syntax Error: {}", err.kind), }) .collect() } -- cgit v1.2.3 From fda8ddc5fe8a764c0dc91fecb92af1bdf3078485 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adolfo=20Ochagav=C3=ADa?= Date: Mon, 5 Nov 2018 18:38:34 +0100 Subject: Introduce Location and make SyntaxError fields private --- crates/ra_editor/src/lib.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'crates/ra_editor/src') 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::{ algo::find_leaf_at_offset, ast::{self, AstNode, NameOwner}, File, + Location, SyntaxKind::{self, *}, SyntaxNodeRef, TextRange, TextUnit, }; @@ -100,11 +101,18 @@ pub fn highlight(file: &File) -> Vec { } pub fn diagnostics(file: &File) -> Vec { + fn location_to_range(location: Location) -> TextRange { + match location { + Location::Offset(offset) => TextRange::offset_len(offset, 1.into()), + Location::Range(range) => range, + } + } + file.errors() .into_iter() .map(|err| Diagnostic { - range: err.range, - msg: format!("Syntax Error: {}", err.kind), + range: location_to_range(err.location()), + msg: format!("Syntax Error: {}", err), }) .collect() } -- cgit v1.2.3