From 13d2fd32ab5df598496c6abbf46591ff05cd3def Mon Sep 17 00:00:00 2001 From: gfreezy Date: Wed, 23 Jan 2019 13:21:29 +0800 Subject: fix completion bugs --- crates/ra_hir/src/code_model_impl/module.rs | 4 ++++ crates/ra_hir/src/nameres.rs | 9 +++++++-- crates/ra_hir/src/path.rs | 7 +++++++ 3 files changed, 18 insertions(+), 2 deletions(-) (limited to 'crates/ra_hir') diff --git a/crates/ra_hir/src/code_model_impl/module.rs b/crates/ra_hir/src/code_model_impl/module.rs index 73c212de8..d94079f11 100644 --- a/crates/ra_hir/src/code_model_impl/module.rs +++ b/crates/ra_hir/src/code_model_impl/module.rs @@ -143,6 +143,10 @@ impl Module { return PerNs::none(); } } + PathKind::Abs => { + // TODO: absolute use is not supported + return PerNs::none(); + } } .def_id, ); diff --git a/crates/ra_hir/src/nameres.rs b/crates/ra_hir/src/nameres.rs index 4874e82f3..72791ed49 100644 --- a/crates/ra_hir/src/nameres.rs +++ b/crates/ra_hir/src/nameres.rs @@ -15,7 +15,8 @@ //! so that the results of name resolution can be preserved unless the module //! structure itself is modified. pub(crate) mod lower; -use lower::*; + +use crate::nameres::lower::*; use std::sync::Arc; @@ -59,7 +60,7 @@ impl ModuleScope { pub struct Resolution { /// None for unresolved pub def_id: PerNs, - /// ident by whitch this is imported into local scope. + /// ident by which this is imported into local scope. pub import: Option, } @@ -317,6 +318,10 @@ where } } PathKind::Crate => module_id.crate_root(&self.module_tree), + PathKind::Abs => { + // TODO: absolute use is not supported for now + return false; + } }; for (i, segment) in import.path.segments.iter().enumerate() { diff --git a/crates/ra_hir/src/path.rs b/crates/ra_hir/src/path.rs index c3d14c689..e13d84c57 100644 --- a/crates/ra_hir/src/path.rs +++ b/crates/ra_hir/src/path.rs @@ -38,6 +38,8 @@ pub enum PathKind { Self_, Super, Crate, + // Absolute path + Abs, } impl Path { @@ -57,6 +59,11 @@ impl Path { let mut segments = Vec::new(); loop { let segment = path.segment()?; + + if segment.has_colon_colon() { + kind = PathKind::Abs; + } + match segment.kind()? { ast::PathSegmentKind::Name(name) => { let args = segment -- cgit v1.2.3