From 9e71dd9799879fc9070f8717f8711fba5dae490a Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Fri, 28 May 2021 02:40:40 +0200 Subject: Only complete modules in empty use-statements --- crates/ide_completion/src/patterns.rs | 7 +++++++ 1 file changed, 7 insertions(+) (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 19e42ba43..7bae7d12c 100644 --- a/crates/ide_completion/src/patterns.rs +++ b/crates/ide_completion/src/patterns.rs @@ -14,6 +14,7 @@ use crate::test_utils::{check_pattern_is_applicable, check_pattern_is_not_applic /// Direct parent container of the cursor position #[derive(Copy, Clone, Debug, PartialEq, Eq)] pub(crate) enum ImmediateLocation { + Use, Impl, Trait, RecordField, @@ -58,6 +59,7 @@ pub(crate) fn determine_location(tok: SyntaxToken) -> Option let res = match_ast! { match parent { ast::IdentPat(_it) => ImmediateLocation::IdentPat, + ast::Use(_it) => ImmediateLocation::Use, ast::BlockExpr(_it) => ImmediateLocation::BlockExpr, ast::SourceFile(_it) => ImmediateLocation::ItemList, ast::ItemList(_it) => ImmediateLocation::ItemList, @@ -87,6 +89,11 @@ fn test_has_trait_parent() { check_location(r"trait A { f$0 }", ImmediateLocation::Trait); } +#[test] +fn test_has_use_parent() { + check_location(r"use f$0", ImmediateLocation::Use); +} + #[test] fn test_has_impl_parent() { check_location(r"impl A { f$0 }", ImmediateLocation::Impl); -- cgit v1.2.3