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') 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