aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists/src/handlers
diff options
context:
space:
mode:
authorKirill Bulatov <[email protected]>2020-02-09 22:22:12 +0000
committerKirill Bulatov <[email protected]>2020-02-12 15:18:41 +0000
commit24ab3e80ca258a3db21bf263225c52d9995a2ea0 (patch)
tree8704eab78d09528e5d81a1fb328abb26fa448c01 /crates/ra_assists/src/handlers
parent5bf669860984a2c058b3bdc3e43b4993a0f25b31 (diff)
Resolve methods and functions better
Diffstat (limited to 'crates/ra_assists/src/handlers')
-rw-r--r--crates/ra_assists/src/handlers/auto_import.rs23
1 files changed, 20 insertions, 3 deletions
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<Assist> {
46 46
47 let name_ref_to_import = 47 let name_ref_to_import =
48 path_under_caret.syntax().descendants().find_map(ast::NameRef::cast)?; 48 path_under_caret.syntax().descendants().find_map(ast::NameRef::cast)?;
49 if source_analyzer 49 if dbg!(source_analyzer
50 .resolve_path(ctx.db, &name_ref_to_import.syntax().ancestors().find_map(ast::Path::cast)?) 50 .resolve_path(ctx.db, &name_ref_to_import.syntax().ancestors().find_map(ast::Path::cast)?))
51 .is_some() 51 .is_some()
52 { 52 {
53 return None; 53 return None;
54 } 54 }
@@ -290,4 +290,21 @@ mod tests {
290 ", 290 ",
291 ); 291 );
292 } 292 }
293
294 #[test]
295 fn not_applicable_for_imported_function() {
296 check_assist_not_applicable(
297 auto_import,
298 r"
299 pub mod test_mod {
300 pub fn test_function() {}
301 }
302
303 use test_mod::test_function;
304 fn main() {
305 test_function<|>
306 }
307 ",
308 );
309 }
293} 310}