mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 22:31:43 +00:00
Make resolve_path cancelable
This commit is contained in:
parent
6bb06addf8
commit
5b0e347f89
2 changed files with 10 additions and 2 deletions
|
@ -157,7 +157,7 @@ fn complete_path(
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
path.segments.pop();
|
path.segments.pop();
|
||||||
let target_module = match module.resolve_path(path) {
|
let target_module = match module.resolve_path(path)? {
|
||||||
None => return Ok(()),
|
None => return Ok(()),
|
||||||
Some(it) => it,
|
Some(it) => it,
|
||||||
};
|
};
|
||||||
|
|
|
@ -133,7 +133,15 @@ impl ModuleDescriptor {
|
||||||
Ok(res)
|
Ok(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn resolve_path(&self, path: Path) -> Option<ModuleDescriptor> {
|
pub(crate) fn resolve_path(&self, path: Path) -> Cancelable<Option<ModuleDescriptor>> {
|
||||||
|
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<ModuleDescriptor> {
|
||||||
let mut curr = match path.kind {
|
let mut curr = match path.kind {
|
||||||
PathKind::Crate => self.crate_root(),
|
PathKind::Crate => self.crate_root(),
|
||||||
PathKind::Self_ | PathKind::Plain => self.clone(),
|
PathKind::Self_ | PathKind::Plain => self.clone(),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue