@@ -24,7 +24,9 @@ use text_edit::TextEdit;
2424
2525use crate :: {
2626 completions:: Completions ,
27- context:: { CompletionContext , IdentContext , NameKind , NameRefContext , NameRefKind } ,
27+ context:: {
28+ CompletionContext , IdentContext , NameContext , NameKind , NameRefContext , NameRefKind ,
29+ } ,
2830} ;
2931
3032pub use crate :: {
@@ -164,63 +166,86 @@ pub fn completions(
164166 let acc = & mut completions;
165167
166168 match & ctx. ident_ctx {
167- IdentContext :: Name ( name_ctx) => {
168- completions:: field:: complete_field_list_record_variant ( acc, ctx, name_ctx) ;
169- completions:: item_list:: trait_impl:: complete_trait_impl_name ( acc, ctx, name_ctx) ;
170- completions:: mod_:: complete_mod ( acc, ctx, name_ctx) ;
171- if let NameKind :: IdentPat ( pattern_ctx) = & name_ctx. kind {
169+ IdentContext :: Name ( NameContext { name, kind } ) => match kind {
170+ NameKind :: Const => {
171+ completions:: item_list:: trait_impl:: complete_trait_impl_const ( acc, ctx, name) ;
172+ }
173+ NameKind :: Function => {
174+ completions:: item_list:: trait_impl:: complete_trait_impl_fn ( acc, ctx, name) ;
175+ }
176+ NameKind :: IdentPat ( pattern_ctx) => {
172177 completions:: flyimport:: import_on_the_fly_pat ( acc, ctx, pattern_ctx) ;
173178 completions:: fn_param:: complete_fn_param ( acc, ctx, pattern_ctx) ;
174179 completions:: pattern:: complete_pattern ( acc, ctx, pattern_ctx) ;
175180 completions:: record:: complete_record_pattern_fields ( acc, ctx, pattern_ctx) ;
176181 }
177- }
178- IdentContext :: NameRef ( name_ctx @ NameRefContext { kind, .. } ) => {
179- completions:: item_list:: trait_impl:: complete_trait_impl_name_ref (
180- acc, ctx, name_ctx,
181- ) ;
182- completions:: use_:: complete_use_tree ( acc, ctx, name_ctx) ;
183-
184- match kind {
185- NameRefKind :: Path ( path_ctx) => {
186- completions:: attribute:: complete_attribute ( acc, ctx, path_ctx) ;
187- completions:: attribute:: complete_derive ( acc, ctx, path_ctx) ;
188- completions:: dot:: complete_undotted_self ( acc, ctx, path_ctx) ;
189- completions:: expr:: complete_expr_path ( acc, ctx, path_ctx) ;
190- completions:: field:: complete_field_list_tuple_variant ( acc, ctx, path_ctx) ;
191- completions:: flyimport:: import_on_the_fly_path ( acc, ctx, path_ctx) ;
192- completions:: item_list:: complete_item_list ( acc, ctx, path_ctx) ;
193- completions:: pattern:: pattern_path_completion ( acc, ctx, path_ctx) ;
194- completions:: r#type:: complete_inferred_type ( acc, ctx, path_ctx) ;
195- completions:: r#type:: complete_type_path ( acc, ctx, path_ctx) ;
196- completions:: record:: complete_record_expr_func_update ( acc, ctx, path_ctx) ;
197- completions:: snippet:: complete_expr_snippet ( acc, ctx, path_ctx) ;
198- completions:: snippet:: complete_item_snippet ( acc, ctx, path_ctx) ;
199- completions:: vis:: complete_vis_path ( acc, ctx, path_ctx) ;
200- }
201- NameRefKind :: DotAccess ( dot_access) => {
202- completions:: flyimport:: import_on_the_fly_dot ( acc, ctx, dot_access) ;
203- completions:: dot:: complete_dot ( acc, ctx, dot_access) ;
204- completions:: postfix:: complete_postfix ( acc, ctx, dot_access) ;
205- }
206- NameRefKind :: Keyword ( item) => {
207- completions:: keyword:: complete_special_keywords ( acc, ctx, item) ;
208- }
209- NameRefKind :: RecordExpr ( record_expr) => {
210- completions:: record:: complete_record_expr_fields_record_expr (
211- acc,
212- ctx,
213- record_expr,
214- ) ;
215- }
216- NameRefKind :: Pattern ( pattern_ctx) => {
217- completions:: flyimport:: import_on_the_fly_pat ( acc, ctx, pattern_ctx) ;
218- completions:: fn_param:: complete_fn_param ( acc, ctx, pattern_ctx) ;
219- completions:: pattern:: complete_pattern ( acc, ctx, pattern_ctx) ;
220- completions:: record:: complete_record_pattern_fields ( acc, ctx, pattern_ctx) ;
221- }
182+ NameKind :: Module ( mod_under_caret) => {
183+ completions:: mod_:: complete_mod ( acc, ctx, mod_under_caret) ;
222184 }
223- }
185+ NameKind :: TypeAlias => {
186+ completions:: item_list:: trait_impl:: complete_trait_impl_type_alias (
187+ acc, ctx, name,
188+ ) ;
189+ }
190+ NameKind :: RecordField => {
191+ completions:: field:: complete_field_list_record_variant ( acc, ctx) ;
192+ }
193+ NameKind :: ConstParam
194+ | NameKind :: Enum
195+ | NameKind :: MacroDef
196+ | NameKind :: MacroRules
197+ | NameKind :: Rename
198+ | NameKind :: SelfParam
199+ | NameKind :: Static
200+ | NameKind :: Struct
201+ | NameKind :: Trait
202+ | NameKind :: TypeParam
203+ | NameKind :: Union
204+ | NameKind :: Variant => ( ) ,
205+ } ,
206+ IdentContext :: NameRef ( NameRefContext { kind, nameref } ) => match kind {
207+ NameRefKind :: Path ( path_ctx) => {
208+ completions:: attribute:: complete_attribute ( acc, ctx, path_ctx) ;
209+ completions:: attribute:: complete_derive ( acc, ctx, path_ctx) ;
210+ completions:: dot:: complete_undotted_self ( acc, ctx, path_ctx) ;
211+ completions:: expr:: complete_expr_path ( acc, ctx, path_ctx) ;
212+ completions:: field:: complete_field_list_tuple_variant ( acc, ctx, path_ctx) ;
213+ completions:: flyimport:: import_on_the_fly_path ( acc, ctx, path_ctx) ;
214+ completions:: item_list:: complete_item_list ( acc, ctx, path_ctx) ;
215+ completions:: item_list:: trait_impl:: complete_trait_impl_name_ref (
216+ acc, ctx, path_ctx, nameref,
217+ ) ;
218+ completions:: pattern:: pattern_path_completion ( acc, ctx, path_ctx) ;
219+ completions:: r#type:: complete_inferred_type ( acc, ctx, path_ctx) ;
220+ completions:: r#type:: complete_type_path ( acc, ctx, path_ctx) ;
221+ completions:: record:: complete_record_expr_func_update ( acc, ctx, path_ctx) ;
222+ completions:: snippet:: complete_expr_snippet ( acc, ctx, path_ctx) ;
223+ completions:: snippet:: complete_item_snippet ( acc, ctx, path_ctx) ;
224+ completions:: use_:: complete_use_tree ( acc, ctx, path_ctx, nameref) ;
225+ completions:: vis:: complete_vis_path ( acc, ctx, path_ctx) ;
226+ }
227+ NameRefKind :: DotAccess ( dot_access) => {
228+ completions:: flyimport:: import_on_the_fly_dot ( acc, ctx, dot_access) ;
229+ completions:: dot:: complete_dot ( acc, ctx, dot_access) ;
230+ completions:: postfix:: complete_postfix ( acc, ctx, dot_access) ;
231+ }
232+ NameRefKind :: Keyword ( item) => {
233+ completions:: keyword:: complete_special_keywords ( acc, ctx, item) ;
234+ }
235+ NameRefKind :: RecordExpr ( record_expr) => {
236+ completions:: record:: complete_record_expr_fields_record_expr (
237+ acc,
238+ ctx,
239+ record_expr,
240+ ) ;
241+ }
242+ NameRefKind :: Pattern ( pattern_ctx) => {
243+ completions:: flyimport:: import_on_the_fly_pat ( acc, ctx, pattern_ctx) ;
244+ completions:: fn_param:: complete_fn_param ( acc, ctx, pattern_ctx) ;
245+ completions:: pattern:: complete_pattern ( acc, ctx, pattern_ctx) ;
246+ completions:: record:: complete_record_pattern_fields ( acc, ctx, pattern_ctx) ;
247+ }
248+ } ,
224249 IdentContext :: Lifetime ( lifetime_ctx) => {
225250 completions:: lifetime:: complete_label ( acc, ctx, lifetime_ctx) ;
226251 completions:: lifetime:: complete_lifetime ( acc, ctx, lifetime_ctx) ;
0 commit comments