Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-completion/src/lib.rs')
| -rw-r--r-- | crates/ide-completion/src/lib.rs | 74 |
1 files changed, 13 insertions, 61 deletions
diff --git a/crates/ide-completion/src/lib.rs b/crates/ide-completion/src/lib.rs index 27fe66e385..90e2628439 100644 --- a/crates/ide-completion/src/lib.rs +++ b/crates/ide-completion/src/lib.rs @@ -24,7 +24,9 @@ use text_edit::TextEdit; use crate::{ completions::Completions, - context::{CompletionContext, IdentContext, NameKind, NameRefContext, NameRefKind}, + context::{ + CompletionContext, IdentContext, NameRefContext, NameRefKind, PathCompletionCtx, PathKind, + }, }; pub use crate::{ @@ -151,10 +153,13 @@ pub fn completions( // prevent `(` from triggering unwanted completion noise if trigger_character == Some('(') { - if let IdentContext::NameRef(NameRefContext { kind: NameRefKind::Path(path_ctx), .. }) = - &ctx.ident_ctx - { - completions::vis::complete_vis_path(&mut completions, ctx, path_ctx); + if let IdentContext::NameRef(NameRefContext { kind, .. }) = &ctx.ident_ctx { + if let NameRefKind::Path( + path_ctx @ PathCompletionCtx { kind: PathKind::Vis { has_in_token }, .. }, + ) = kind + { + completions::vis::complete_vis_path(&mut completions, ctx, path_ctx, has_in_token); + } } // prevent `(` from triggering unwanted completion noise return Some(completions); @@ -164,62 +169,9 @@ pub fn completions( let acc = &mut completions; match &ctx.ident_ctx { - IdentContext::Name(name_ctx) => { - completions::field::complete_field_list_record_variant(acc, ctx, name_ctx); - completions::item_list::trait_impl::complete_trait_impl_name(acc, ctx, name_ctx); - completions::mod_::complete_mod(acc, ctx, name_ctx); - if let NameKind::IdentPat(pattern_ctx) = &name_ctx.kind { - completions::flyimport::import_on_the_fly_pat(acc, ctx, pattern_ctx); - completions::fn_param::complete_fn_param(acc, ctx, pattern_ctx); - completions::pattern::complete_pattern(acc, ctx, pattern_ctx); - completions::record::complete_record_pattern_fields(acc, ctx, pattern_ctx); - } - } - IdentContext::NameRef(name_ctx @ NameRefContext { kind, .. }) => { - completions::item_list::trait_impl::complete_trait_impl_name_ref( - acc, ctx, name_ctx, - ); - completions::use_::complete_use_tree(acc, ctx, name_ctx); - - match kind { - NameRefKind::Path(path_ctx) => { - completions::attribute::complete_attribute(acc, ctx, path_ctx); - completions::attribute::complete_derive(acc, ctx, path_ctx); - completions::dot::complete_undotted_self(acc, ctx, path_ctx); - completions::expr::complete_expr_path(acc, ctx, path_ctx); - completions::field::complete_field_list_tuple_variant(acc, ctx, path_ctx); - completions::flyimport::import_on_the_fly_path(acc, ctx, path_ctx); - completions::item_list::complete_item_list(acc, ctx, path_ctx); - completions::pattern::pattern_path_completion(acc, ctx, path_ctx); - completions::r#type::complete_inferred_type(acc, ctx, path_ctx); - completions::r#type::complete_type_path(acc, ctx, path_ctx); - completions::record::complete_record_expr_func_update(acc, ctx, path_ctx); - completions::snippet::complete_expr_snippet(acc, ctx, path_ctx); - completions::snippet::complete_item_snippet(acc, ctx, path_ctx); - completions::vis::complete_vis_path(acc, ctx, path_ctx); - } - NameRefKind::DotAccess(dot_access) => { - completions::flyimport::import_on_the_fly_dot(acc, ctx, dot_access); - completions::dot::complete_dot(acc, ctx, dot_access); - completions::postfix::complete_postfix(acc, ctx, dot_access); - } - NameRefKind::Keyword(item) => { - completions::keyword::complete_special_keywords(acc, ctx, item); - } - NameRefKind::RecordExpr(record_expr) => { - completions::record::complete_record_expr_fields_record_expr( - acc, - ctx, - record_expr, - ); - } - NameRefKind::Pattern(pattern_ctx) => { - completions::flyimport::import_on_the_fly_pat(acc, ctx, pattern_ctx); - completions::fn_param::complete_fn_param(acc, ctx, pattern_ctx); - completions::pattern::complete_pattern(acc, ctx, pattern_ctx); - completions::record::complete_record_pattern_fields(acc, ctx, pattern_ctx); - } - } + IdentContext::Name(name_ctx) => completions::complete_name(acc, ctx, name_ctx), + IdentContext::NameRef(name_ref_ctx) => { + completions::complete_name_ref(acc, ctx, name_ref_ctx) } IdentContext::Lifetime(lifetime_ctx) => { completions::lifetime::complete_label(acc, ctx, lifetime_ctx); |