From 24ab3e80ca258a3db21bf263225c52d9995a2ea0 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Mon, 10 Feb 2020 00:22:12 +0200 Subject: Resolve methods and functions better --- crates/ra_assists/src/handlers/auto_import.rs | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'crates/ra_assists/src/handlers') diff --git a/crates/ra_assists/src/handlers/auto_import.rs b/crates/ra_assists/src/handlers/auto_import.rs index 1fb701da5..10984d8ad 100644 --- a/crates/ra_assists/src/handlers/auto_import.rs +++ b/crates/ra_assists/src/handlers/auto_import.rs @@ -46,9 +46,9 @@ pub(crate) fn auto_import(ctx: AssistCtx) -> Option { let name_ref_to_import = path_under_caret.syntax().descendants().find_map(ast::NameRef::cast)?; - if source_analyzer - .resolve_path(ctx.db, &name_ref_to_import.syntax().ancestors().find_map(ast::Path::cast)?) - .is_some() + if dbg!(source_analyzer + .resolve_path(ctx.db, &name_ref_to_import.syntax().ancestors().find_map(ast::Path::cast)?)) + .is_some() { return None; } @@ -290,4 +290,21 @@ mod tests { ", ); } + + #[test] + fn not_applicable_for_imported_function() { + check_assist_not_applicable( + auto_import, + r" + pub mod test_mod { + pub fn test_function() {} + } + + use test_mod::test_function; + fn main() { + test_function<|> + } + ", + ); + } } -- cgit v1.2.3