diff options
Diffstat (limited to 'crates/assists')
-rw-r--r-- | crates/assists/src/handlers/add_missing_impl_members.rs | 35 | ||||
-rw-r--r-- | crates/assists/src/handlers/auto_import.rs | 33 | ||||
-rw-r--r-- | crates/assists/src/utils/insert_use.rs | 10 |
3 files changed, 66 insertions, 12 deletions
diff --git a/crates/assists/src/handlers/add_missing_impl_members.rs b/crates/assists/src/handlers/add_missing_impl_members.rs index 8df1d786b..1ac5fefd6 100644 --- a/crates/assists/src/handlers/add_missing_impl_members.rs +++ b/crates/assists/src/handlers/add_missing_impl_members.rs | |||
@@ -415,6 +415,41 @@ impl foo::Foo for S { | |||
415 | } | 415 | } |
416 | 416 | ||
417 | #[test] | 417 | #[test] |
418 | fn test_qualify_path_2() { | ||
419 | check_assist( | ||
420 | add_missing_impl_members, | ||
421 | r#" | ||
422 | mod foo { | ||
423 | pub mod bar { | ||
424 | pub struct Bar; | ||
425 | pub trait Foo { fn foo(&self, bar: Bar); } | ||
426 | } | ||
427 | } | ||
428 | |||
429 | use foo::bar; | ||
430 | |||
431 | struct S; | ||
432 | impl bar::Foo for S { <|> }"#, | ||
433 | r#" | ||
434 | mod foo { | ||
435 | pub mod bar { | ||
436 | pub struct Bar; | ||
437 | pub trait Foo { fn foo(&self, bar: Bar); } | ||
438 | } | ||
439 | } | ||
440 | |||
441 | use foo::bar; | ||
442 | |||
443 | struct S; | ||
444 | impl bar::Foo for S { | ||
445 | fn foo(&self, bar: bar::Bar) { | ||
446 | ${0:todo!()} | ||
447 | } | ||
448 | }"#, | ||
449 | ); | ||
450 | } | ||
451 | |||
452 | #[test] | ||
418 | fn test_qualify_path_generic() { | 453 | fn test_qualify_path_generic() { |
419 | check_assist( | 454 | check_assist( |
420 | add_missing_impl_members, | 455 | add_missing_impl_members, |
diff --git a/crates/assists/src/handlers/auto_import.rs b/crates/assists/src/handlers/auto_import.rs index b5eb2c722..ee7277c04 100644 --- a/crates/assists/src/handlers/auto_import.rs +++ b/crates/assists/src/handlers/auto_import.rs | |||
@@ -196,10 +196,10 @@ impl AutoImportAssets { | |||
196 | }) | 196 | }) |
197 | .filter_map(|candidate| match candidate { | 197 | .filter_map(|candidate| match candidate { |
198 | Either::Left(module_def) => { | 198 | Either::Left(module_def) => { |
199 | self.module_with_name_to_import.find_use_path(db, module_def) | 199 | self.module_with_name_to_import.find_use_path_prefixed(db, module_def) |
200 | } | 200 | } |
201 | Either::Right(macro_def) => { | 201 | Either::Right(macro_def) => { |
202 | self.module_with_name_to_import.find_use_path(db, macro_def) | 202 | self.module_with_name_to_import.find_use_path_prefixed(db, macro_def) |
203 | } | 203 | } |
204 | }) | 204 | }) |
205 | .filter(|use_path| !use_path.segments.is_empty()) | 205 | .filter(|use_path| !use_path.segments.is_empty()) |
@@ -291,6 +291,35 @@ mod tests { | |||
291 | use crate::tests::{check_assist, check_assist_not_applicable, check_assist_target}; | 291 | use crate::tests::{check_assist, check_assist_not_applicable, check_assist_target}; |
292 | 292 | ||
293 | #[test] | 293 | #[test] |
294 | fn applicable_when_found_an_import_partial() { | ||
295 | check_assist( | ||
296 | auto_import, | ||
297 | r" | ||
298 | mod std { | ||
299 | pub mod fmt { | ||
300 | pub struct Formatter; | ||
301 | } | ||
302 | } | ||
303 | |||
304 | use std::fmt; | ||
305 | |||
306 | <|>Formatter | ||
307 | ", | ||
308 | r" | ||
309 | mod std { | ||
310 | pub mod fmt { | ||
311 | pub struct Formatter; | ||
312 | } | ||
313 | } | ||
314 | |||
315 | use std::fmt::{self, Formatter}; | ||
316 | |||
317 | Formatter | ||
318 | ", | ||
319 | ); | ||
320 | } | ||
321 | |||
322 | #[test] | ||
294 | fn applicable_when_found_an_import() { | 323 | fn applicable_when_found_an_import() { |
295 | check_assist( | 324 | check_assist( |
296 | auto_import, | 325 | auto_import, |
diff --git a/crates/assists/src/utils/insert_use.rs b/crates/assists/src/utils/insert_use.rs index 09f4a2224..5719b06af 100644 --- a/crates/assists/src/utils/insert_use.rs +++ b/crates/assists/src/utils/insert_use.rs | |||
@@ -810,16 +810,6 @@ use std::io;", | |||
810 | } | 810 | } |
811 | 811 | ||
812 | #[test] | 812 | #[test] |
813 | #[ignore] // FIXME: Support this | ||
814 | fn merge_partial_path() { | ||
815 | check_full( | ||
816 | "ast::Foo", | ||
817 | r"use syntax::{ast, algo};", | ||
818 | r"use syntax::{ast::{self, Foo}, algo};", | ||
819 | ) | ||
820 | } | ||
821 | |||
822 | #[test] | ||
823 | fn merge_glob_nested() { | 813 | fn merge_glob_nested() { |
824 | check_full( | 814 | check_full( |
825 | "foo::bar::quux::Fez", | 815 | "foo::bar::quux::Fez", |