From 2225db2eb48bd8c8fdf399c50652d3f95c851ace Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Thu, 17 Jun 2021 13:56:55 +0200 Subject: Refine `self`, `super` and `crate` completion in use paths --- crates/ide_completion/src/patterns.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'crates/ide_completion/src/patterns.rs') diff --git a/crates/ide_completion/src/patterns.rs b/crates/ide_completion/src/patterns.rs index 62e4334de..271409c38 100644 --- a/crates/ide_completion/src/patterns.rs +++ b/crates/ide_completion/src/patterns.rs @@ -27,6 +27,7 @@ pub(crate) enum ImmediatePrevSibling { #[derive(Clone, Debug, PartialEq, Eq)] pub(crate) enum ImmediateLocation { Use, + UseTree, Impl, Trait, RecordField, @@ -180,6 +181,8 @@ pub(crate) fn determine_location( match parent { ast::IdentPat(_it) => ImmediateLocation::IdentPat, ast::Use(_it) => ImmediateLocation::Use, + ast::UseTree(_it) => ImmediateLocation::UseTree, + ast::UseTreeList(_it) => ImmediateLocation::UseTree, ast::BlockExpr(_it) => ImmediateLocation::BlockExpr, ast::SourceFile(_it) => ImmediateLocation::ItemList, ast::ItemList(_it) => ImmediateLocation::ItemList, @@ -373,8 +376,8 @@ mod tests { fn test_use_loc() { check_location(r"use f$0", ImmediateLocation::Use); check_location(r"use f$0;", ImmediateLocation::Use); - check_location(r"use f::{f$0}", None); - check_location(r"use {f$0}", None); + check_location(r"use f::{f$0}", ImmediateLocation::UseTree); + check_location(r"use {f$0}", ImmediateLocation::UseTree); } #[test] -- cgit v1.2.3