Complete paths after ::

This commit is contained in:
Aleksey Kladov 2018-11-21 18:34:20 +03:00
parent 7ffc7d3308
commit edeec6a414
5 changed files with 5 additions and 9 deletions

View File

@ -224,7 +224,7 @@ fn test_completion_mod_scope_no_self_use() {
fn test_completion_self_path() { fn test_completion_self_path() {
check_scope_completion( check_scope_completion(
r" r"
use self::m::B<|>; use self::m::<|>;
mod m { mod m {
struct Bar; struct Bar;

View File

@ -110,6 +110,7 @@ pub fn crate_root(&self) -> ModuleDescriptor {
} }
/// `name` is `None` for the crate's root module /// `name` is `None` for the crate's root module
#[allow(unused)]
pub fn name(&self) -> Option<SmolStr> { pub fn name(&self) -> Option<SmolStr> {
let link = self.module_id.parent_link(&self.tree)?; let link = self.module_id.parent_link(&self.tree)?;
Some(link.name(&self.tree)) Some(link.name(&self.tree))

View File

@ -148,12 +148,7 @@ pub fn find_node_at_offset<'a, N: AstNode<'a>>(
syntax: SyntaxNodeRef<'a>, syntax: SyntaxNodeRef<'a>,
offset: TextUnit, offset: TextUnit,
) -> Option<N> { ) -> Option<N> {
let leaves = find_leaf_at_offset(syntax, offset); find_leaf_at_offset(syntax, offset).find_map(|leaf| leaf.ancestors().find_map(N::cast))
let leaf = leaves
.clone()
.find(|leaf| !leaf.kind().is_trivia())
.or_else(|| leaves.right_biased())?;
leaf.ancestors().filter_map(N::cast).next()
} }
#[cfg(test)] #[cfg(test)]

View File

@ -29,7 +29,7 @@ pub(super) enum ItemFlavor {
Trait, Trait,
} }
const ITEM_RECOVERY_SET: TokenSet = token_set![ pub(super) const ITEM_RECOVERY_SET: TokenSet = token_set![
FN_KW, STRUCT_KW, ENUM_KW, IMPL_KW, TRAIT_KW, CONST_KW, STATIC_KW, LET_KW, MOD_KW, PUB_KW, FN_KW, STRUCT_KW, ENUM_KW, IMPL_KW, TRAIT_KW, CONST_KW, STATIC_KW, LET_KW, MOD_KW, PUB_KW,
CRATE_KW CRATE_KW
]; ];

View File

@ -78,7 +78,7 @@ fn path_segment(p: &mut Parser, mode: Mode, first: bool) {
// use crate::foo; // use crate::foo;
SELF_KW | SUPER_KW | CRATE_KW => p.bump(), SELF_KW | SUPER_KW | CRATE_KW => p.bump(),
_ => { _ => {
p.err_and_bump("expected identifier"); p.err_recover("expected identifier", items::ITEM_RECOVERY_SET);
} }
}; };
} }