diff options
Diffstat (limited to 'crates/libanalysis')
-rw-r--r-- | crates/libanalysis/src/lib.rs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/crates/libanalysis/src/lib.rs b/crates/libanalysis/src/lib.rs index 7a34d354e..fe2c3c2e6 100644 --- a/crates/libanalysis/src/lib.rs +++ b/crates/libanalysis/src/lib.rs | |||
@@ -15,6 +15,7 @@ mod module_map; | |||
15 | use std::{ | 15 | use std::{ |
16 | fmt, | 16 | fmt, |
17 | path::{Path, PathBuf}, | 17 | path::{Path, PathBuf}, |
18 | panic, | ||
18 | sync::{ | 19 | sync::{ |
19 | Arc, | 20 | Arc, |
20 | atomic::{AtomicBool, Ordering::SeqCst}, | 21 | atomic::{AtomicBool, Ordering::SeqCst}, |
@@ -307,8 +308,15 @@ impl FileData { | |||
307 | } | 308 | } |
308 | 309 | ||
309 | fn syntax(&self) -> &File { | 310 | fn syntax(&self) -> &File { |
310 | self.syntax | 311 | let text = &self.text; |
311 | .get_or_init(|| File::parse(&self.text)) | 312 | let syntax = &self.syntax; |
313 | match panic::catch_unwind(panic::AssertUnwindSafe(|| syntax.get_or_init(|| File::parse(text)))) { | ||
314 | Ok(file) => file, | ||
315 | Err(err) => { | ||
316 | error!("Parser paniced on:\n------\n{}\n------\n", &self.text); | ||
317 | panic::resume_unwind(err) | ||
318 | } | ||
319 | } | ||
312 | } | 320 | } |
313 | 321 | ||
314 | fn syntax_transient(&self) -> File { | 322 | fn syntax_transient(&self) -> File { |