|
2 | 2 |
|
3 | 3 | use crate::{ |
4 | 4 | completions::module_or_fn_macro, |
5 | | - context::{ItemListKind, PathCompletionCtx, PathKind, Qualified}, |
| 5 | + context::{ItemListKind, NameRefContext, NameRefKind, PathCompletionCtx, PathKind, Qualified}, |
6 | 6 | CompletionContext, Completions, |
7 | 7 | }; |
8 | 8 |
|
9 | | -mod trait_impl; |
| 9 | +pub(crate) mod trait_impl; |
10 | 10 |
|
11 | | -pub(crate) fn complete_item_list(acc: &mut Completions, ctx: &CompletionContext) { |
| 11 | +pub(crate) fn complete_item_list( |
| 12 | + acc: &mut Completions, |
| 13 | + ctx: &CompletionContext, |
| 14 | + name_ref_ctx: &NameRefContext, |
| 15 | +) { |
12 | 16 | let _p = profile::span("complete_item_list"); |
13 | 17 |
|
14 | | - if let Some(_) = ctx.name_ctx() { |
15 | | - trait_impl::complete_trait_impl(acc, ctx); |
16 | | - return; |
17 | | - } |
18 | | - |
19 | | - let (qualified, kind, is_trivial_path) = match ctx.path_context() { |
20 | | - Some(ctx @ PathCompletionCtx { kind: PathKind::Item { kind }, qualified, .. }) => { |
21 | | - (qualified, Some(kind), ctx.is_trivial_path()) |
22 | | - } |
23 | | - Some( |
24 | | - ctx @ PathCompletionCtx { |
25 | | - kind: PathKind::Expr { in_block_expr: true, .. }, |
26 | | - qualified, |
27 | | - .. |
28 | | - }, |
29 | | - ) => (qualified, None, ctx.is_trivial_path()), |
| 18 | + let (qualified, item_list_kind, is_trivial_path) = match name_ref_ctx { |
| 19 | + NameRefContext { |
| 20 | + kind: |
| 21 | + Some(NameRefKind::Path( |
| 22 | + ctx @ PathCompletionCtx { kind: PathKind::Item { kind }, qualified, .. }, |
| 23 | + )), |
| 24 | + .. |
| 25 | + } => (qualified, Some(kind), ctx.is_trivial_path()), |
| 26 | + NameRefContext { |
| 27 | + kind: |
| 28 | + Some(NameRefKind::Path( |
| 29 | + ctx @ PathCompletionCtx { |
| 30 | + kind: PathKind::Expr { in_block_expr: true, .. }, |
| 31 | + qualified, |
| 32 | + .. |
| 33 | + }, |
| 34 | + )), |
| 35 | + .. |
| 36 | + } => (qualified, None, ctx.is_trivial_path()), |
30 | 37 | _ => return, |
31 | 38 | }; |
32 | 39 |
|
33 | | - if matches!(kind, Some(ItemListKind::TraitImpl)) { |
34 | | - trait_impl::complete_trait_impl(acc, ctx); |
| 40 | + if matches!(item_list_kind, Some(ItemListKind::TraitImpl)) { |
| 41 | + trait_impl::complete_trait_impl_name_ref(acc, ctx, name_ref_ctx); |
35 | 42 | } |
36 | 43 |
|
37 | 44 | if is_trivial_path { |
38 | | - add_keywords(acc, ctx, kind); |
| 45 | + add_keywords(acc, ctx, item_list_kind); |
39 | 46 | } |
40 | 47 |
|
41 | | - if kind.is_none() { |
| 48 | + if item_list_kind.is_none() { |
42 | 49 | // this is already handled by expression |
43 | 50 | return; |
44 | 51 | } |
|
0 commit comments