From 3c68da792b52b9071e7e9bdac2b1cf8eb3c9e77b Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 12 Sep 2019 12:38:07 +0300 Subject: don't break parser error recovery in presence of macros Parser has the invariant that `{}` are balanced. Previous code tried (unsucesfuly) maintain the same invariant for `$()` as well, but it was done in a rather ad-hoc manner: it's not at all obvious that it is possible to maintain both invariants! --- crates/ra_batch/src/lib.rs | 4 ++++ crates/ra_parser/src/parser.rs | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/crates/ra_batch/src/lib.rs b/crates/ra_batch/src/lib.rs index a14139b26..ffc9e16bb 100644 --- a/crates/ra_batch/src/lib.rs +++ b/crates/ra_batch/src/lib.rs @@ -89,6 +89,10 @@ pub fn load( vfs.root2path(root) ); analysis_change.add_root(source_root_id, is_local); + analysis_change.set_debug_root_path( + source_root_id, + source_roots[&source_root_id].path().display().to_string(), + ); let mut file_map = FxHashMap::default(); for (vfs_file, path, text) in files { diff --git a/crates/ra_parser/src/parser.rs b/crates/ra_parser/src/parser.rs index a2ac363fb..f8fba6860 100644 --- a/crates/ra_parser/src/parser.rs +++ b/crates/ra_parser/src/parser.rs @@ -5,7 +5,7 @@ use drop_bomb::DropBomb; use crate::{ event::Event, ParseError, - SyntaxKind::{self, EOF, ERROR, L_DOLLAR, R_DOLLAR, TOMBSTONE}, + SyntaxKind::{self, EOF, ERROR, TOMBSTONE}, TokenSet, TokenSource, T, }; @@ -212,7 +212,7 @@ impl<'t> Parser<'t> { /// Create an error node and consume the next token. pub(crate) fn err_recover(&mut self, message: &str, recovery: TokenSet) { match self.current() { - T!['{'] | T!['}'] | L_DOLLAR | R_DOLLAR => { + T!['{'] | T!['}'] => { self.error(message); return; } -- cgit v1.2.3