mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-15 22:54:00 +00:00
fix: Trigger flyimport completions in item lists again
This commit is contained in:
parent
ed44fe52e4
commit
cd42b20ce3
2 changed files with 28 additions and 4 deletions
|
@ -5,7 +5,10 @@ use ide_db::imports::{
|
|||
insert_use::ImportScope,
|
||||
};
|
||||
use itertools::Itertools;
|
||||
use syntax::{ast, AstNode, SyntaxNode, T};
|
||||
use syntax::{
|
||||
ast::{self},
|
||||
AstNode, SyntaxNode, T,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
context::{
|
||||
|
@ -123,6 +126,7 @@ pub(crate) fn import_on_the_fly_path(
|
|||
| PathKind::Type { .. }
|
||||
| PathKind::Attr { .. }
|
||||
| PathKind::Derive { .. }
|
||||
| PathKind::Item { .. }
|
||||
| PathKind::Pat { .. },
|
||||
qualified,
|
||||
..
|
||||
|
@ -161,7 +165,7 @@ pub(crate) fn import_on_the_fly_pat(
|
|||
let potential_import_name = import_name(ctx);
|
||||
let import_assets = import_assets_for_path(ctx, &potential_import_name, None)?;
|
||||
|
||||
import_on_the_fly_pat2(
|
||||
import_on_the_fly_pat_(
|
||||
acc,
|
||||
ctx,
|
||||
pattern_ctx,
|
||||
|
@ -227,7 +231,7 @@ fn import_on_the_fly(
|
|||
| PathKind::Pat { .. },
|
||||
ItemInNs::Macros(mac),
|
||||
) => mac.is_fn_like(ctx.db),
|
||||
(PathKind::Item { .. }, _) => true,
|
||||
(PathKind::Item { .. }, ..) => false,
|
||||
|
||||
(PathKind::Expr { .. }, ItemInNs::Types(_) | ItemInNs::Values(_)) => true,
|
||||
|
||||
|
@ -279,7 +283,7 @@ fn import_on_the_fly(
|
|||
Some(())
|
||||
}
|
||||
|
||||
fn import_on_the_fly_pat2(
|
||||
fn import_on_the_fly_pat_(
|
||||
acc: &mut Completions,
|
||||
ctx: &CompletionContext,
|
||||
pattern_ctx: &PatternContext,
|
||||
|
|
|
@ -1210,3 +1210,23 @@ fn f<T>() where T: Comp$0
|
|||
"#]],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn flyimport_source_file() {
|
||||
check(
|
||||
r#"
|
||||
//- /main.rs crate:main deps:dep
|
||||
def$0
|
||||
//- /lib.rs crate:dep
|
||||
#[macro_export]
|
||||
macro_rules! define_struct {
|
||||
() => {
|
||||
pub struct Foo;
|
||||
};
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
ma define_struct!(…) (use dep::define_struct) macro_rules! define_struct
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue