From 5b0e347f89be317d21fd894c0ccf4abee5645429 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 27 Nov 2018 16:30:02 +0300 Subject: Make resolve_path cancelable --- crates/ra_analysis/src/completion/reference_completion.rs | 2 +- crates/ra_analysis/src/descriptors/module/mod.rs | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'crates/ra_analysis') diff --git a/crates/ra_analysis/src/completion/reference_completion.rs b/crates/ra_analysis/src/completion/reference_completion.rs index 1faa70a18..41df881b3 100644 --- a/crates/ra_analysis/src/completion/reference_completion.rs +++ b/crates/ra_analysis/src/completion/reference_completion.rs @@ -157,7 +157,7 @@ fn complete_path( return Ok(()); } path.segments.pop(); - let target_module = match module.resolve_path(path) { + let target_module = match module.resolve_path(path)? { None => return Ok(()), Some(it) => it, }; diff --git a/crates/ra_analysis/src/descriptors/module/mod.rs b/crates/ra_analysis/src/descriptors/module/mod.rs index a6eaec178..f5238e239 100644 --- a/crates/ra_analysis/src/descriptors/module/mod.rs +++ b/crates/ra_analysis/src/descriptors/module/mod.rs @@ -133,7 +133,15 @@ impl ModuleDescriptor { Ok(res) } - pub(crate) fn resolve_path(&self, path: Path) -> Option { + pub(crate) fn resolve_path(&self, path: Path) -> Cancelable> { + let res = match self.do_resolve_path(path) { + None => return Ok(None), + Some(it) => it, + }; + Ok(Some(res)) + } + + fn do_resolve_path(&self, path: Path) -> Option { let mut curr = match path.kind { PathKind::Crate => self.crate_root(), PathKind::Self_ | PathKind::Plain => self.clone(), -- cgit v1.2.3