aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/nameres.rs
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-02-11 14:02:59 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-02-11 14:02:59 +0000
commit821d980fd950679315bb12659a13347233895e67 (patch)
treebce5924d76aac4d0368081371e46b0d5f2ee1ad9 /crates/ra_hir/src/nameres.rs
parentca1b0a123119b80d0cbbea2f18124640423efd8b (diff)
parent58ed8ee6650058d5dc4ce511e2d9c04fdfa09aaf (diff)
Merge #785
785: Fix completion of paths r=flodiebold a=matklad r? @flodiebold Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/nameres.rs')
-rw-r--r--crates/ra_hir/src/nameres.rs22
1 files changed, 9 insertions, 13 deletions
diff --git a/crates/ra_hir/src/nameres.rs b/crates/ra_hir/src/nameres.rs
index 94f7db024..4b8097235 100644
--- a/crates/ra_hir/src/nameres.rs
+++ b/crates/ra_hir/src/nameres.rs
@@ -434,6 +434,14 @@ impl ItemMap {
434 self.resolve_path_fp(db, original_module, path).0 434 self.resolve_path_fp(db, original_module, path).0
435 } 435 }
436 436
437 pub(crate) fn resolve_name_in_module(&self, module: Module, name: &Name) -> PerNs<ModuleDef> {
438 let from_scope = self[module.module_id].items.get(name).map_or(PerNs::none(), |it| it.def);
439 let from_extern_prelude =
440 self.extern_prelude.get(name).map_or(PerNs::none(), |&it| PerNs::types(it));
441
442 from_scope.combine(from_extern_prelude)
443 }
444
437 // Returns Yes if we are sure that additions to `ItemMap` wouldn't change 445 // Returns Yes if we are sure that additions to `ItemMap` wouldn't change
438 // the result. 446 // the result.
439 fn resolve_path_fp( 447 fn resolve_path_fp(
@@ -451,19 +459,7 @@ impl ItemMap {
451 Some((_, segment)) => segment, 459 Some((_, segment)) => segment,
452 None => return (PerNs::none(), ReachedFixedPoint::Yes), 460 None => return (PerNs::none(), ReachedFixedPoint::Yes),
453 }; 461 };
454 // Resolve in: 462 self.resolve_name_in_module(original_module, &segment.name)
455 // - current module / scope
456 // - extern prelude
457 match self[original_module.module_id].items.get(&segment.name) {
458 Some(res) if !res.def.is_none() => res.def,
459 _ => {
460 if let Some(def) = self.extern_prelude.get(&segment.name) {
461 PerNs::types(*def)
462 } else {
463 return (PerNs::none(), ReachedFixedPoint::No);
464 }
465 }
466 }
467 } 463 }
468 PathKind::Super => { 464 PathKind::Super => {
469 if let Some(p) = original_module.parent(db) { 465 if let Some(p) = original_module.parent(db) {