@@ -22,7 +22,7 @@ pub(crate) mod vis;
2222
2323use std:: iter;
2424
25- use hir:: { db :: HirDatabase , known, ScopeDef } ;
25+ use hir:: { known, ScopeDef } ;
2626use ide_db:: SymbolKind ;
2727use syntax:: ast;
2828
@@ -46,22 +46,6 @@ use crate::{
4646 CompletionContext , CompletionItem , CompletionItemKind ,
4747} ;
4848
49- fn module_or_attr ( db : & dyn HirDatabase , def : ScopeDef ) -> Option < ScopeDef > {
50- match def {
51- ScopeDef :: ModuleDef ( hir:: ModuleDef :: Macro ( m) ) if m. is_attr ( db) => Some ( def) ,
52- ScopeDef :: ModuleDef ( hir:: ModuleDef :: Module ( _) ) => Some ( def) ,
53- _ => None ,
54- }
55- }
56-
57- fn module_or_fn_macro ( db : & dyn HirDatabase , def : ScopeDef ) -> Option < ScopeDef > {
58- match def {
59- ScopeDef :: ModuleDef ( hir:: ModuleDef :: Macro ( m) ) if m. is_fn_like ( db) => Some ( def) ,
60- ScopeDef :: ModuleDef ( hir:: ModuleDef :: Module ( _) ) => Some ( def) ,
61- _ => None ,
62- }
63- }
64-
6549/// Represents an in-progress set of completions being built.
6650#[ derive( Debug , Default ) ]
6751pub struct Completions {
@@ -184,6 +168,15 @@ impl Completions {
184168 self . add ( render_resolution_simple ( RenderContext :: new ( ctx) , local_name, resolution) . build ( ) ) ;
185169 }
186170
171+ pub ( crate ) fn add_module (
172+ & mut self ,
173+ ctx : & CompletionContext ,
174+ module : hir:: Module ,
175+ local_name : hir:: Name ,
176+ ) {
177+ self . add_resolution ( ctx, local_name, hir:: ScopeDef :: ModuleDef ( module. into ( ) ) ) ;
178+ }
179+
187180 pub ( crate ) fn add_macro (
188181 & mut self ,
189182 ctx : & CompletionContext ,
@@ -486,16 +479,19 @@ pub(super) fn complete_name_ref(
486479 match kind {
487480 NameRefKind :: Path ( path_ctx) => {
488481 flyimport:: import_on_the_fly_path ( acc, ctx, path_ctx) ;
482+
489483 match & path_ctx. kind {
490484 PathKind :: Expr { expr_ctx } => {
491- dot:: complete_undotted_self ( acc, ctx, path_ctx, expr_ctx) ;
492485 expr:: complete_expr_path ( acc, ctx, path_ctx, expr_ctx) ;
486+
487+ dot:: complete_undotted_self ( acc, ctx, path_ctx, expr_ctx) ;
493488 item_list:: complete_item_list_in_expr ( acc, ctx, path_ctx, expr_ctx) ;
494489 record:: complete_record_expr_func_update ( acc, ctx, path_ctx, expr_ctx) ;
495490 snippet:: complete_expr_snippet ( acc, ctx, path_ctx, expr_ctx) ;
496491 }
497492 PathKind :: Type { location } => {
498493 r#type:: complete_type_path ( acc, ctx, path_ctx, location) ;
494+
499495 match location {
500496 TypeLocation :: TupleField => {
501497 field:: complete_field_list_tuple_variant ( acc, ctx, path_ctx) ;
@@ -511,13 +507,14 @@ pub(super) fn complete_name_ref(
511507 }
512508 }
513509 PathKind :: Attr { attr_ctx } => {
514- attribute:: complete_attribute ( acc, ctx, path_ctx, attr_ctx) ;
510+ attribute:: complete_attribute_path ( acc, ctx, path_ctx, attr_ctx) ;
515511 }
516512 PathKind :: Derive { existing_derives } => {
517- attribute:: complete_derive ( acc, ctx, path_ctx, existing_derives) ;
513+ attribute:: complete_derive_path ( acc, ctx, path_ctx, existing_derives) ;
518514 }
519515 PathKind :: Item { kind } => {
520516 item_list:: complete_item_list ( acc, ctx, path_ctx, kind) ;
517+
521518 snippet:: complete_item_snippet ( acc, ctx, path_ctx, kind) ;
522519 if let ItemListKind :: TraitImpl ( impl_) = kind {
523520 item_list:: trait_impl:: complete_trait_impl_item_by_name (
@@ -532,7 +529,7 @@ pub(super) fn complete_name_ref(
532529 vis:: complete_vis_path ( acc, ctx, path_ctx, has_in_token) ;
533530 }
534531 PathKind :: Use => {
535- use_:: complete_use_tree ( acc, ctx, path_ctx, nameref) ;
532+ use_:: complete_use_path ( acc, ctx, path_ctx, nameref) ;
536533 }
537534 }
538535 }
0 commit comments