33use std:: iter;
44
55use hir:: { Module , ModuleSource } ;
6- use ide_db:: FxHashSet ;
76use ide_db:: {
87 base_db:: { SourceDatabaseExt , VfsPath } ,
9- RootDatabase , SymbolKind ,
8+ FxHashSet , RootDatabase , SymbolKind ,
109} ;
1110use syntax:: { ast, AstNode , SyntaxKind } ;
1211
13- use crate :: { context:: NameContext , CompletionItem } ;
14-
15- use crate :: { context:: CompletionContext , Completions } ;
12+ use crate :: {
13+ context:: { CompletionContext , NameContext , NameKind } ,
14+ CompletionItem , Completions ,
15+ } ;
1616
17- /// Complete mod declaration, i.e. `mod $0 ;`
17+ /// Complete mod declaration, i.e. `mod ;`
1818pub ( crate ) fn complete_mod ( acc : & mut Completions , ctx : & CompletionContext ) -> Option < ( ) > {
1919 let mod_under_caret = match & ctx. name_ctx {
20- Some ( NameContext :: Module ( mod_under_caret) ) if mod_under_caret. item_list ( ) . is_none ( ) => {
20+ Some ( NameContext { kind : NameKind :: Module ( mod_under_caret) , .. } )
21+ if mod_under_caret. item_list ( ) . is_none ( ) =>
22+ {
2123 mod_under_caret
2224 }
2325 _ => return None ,
@@ -26,7 +28,7 @@ pub(crate) fn complete_mod(acc: &mut Completions, ctx: &CompletionContext) -> Op
2628 let _p = profile:: span ( "completion::complete_mod" ) ;
2729
2830 let mut current_module = ctx. module ;
29- // For `mod $0 `, `ctx.module` is its parent, but for `mod f$0 `, it's `mod f` itself, but we're
31+ // For `mod `, `ctx.module` is its parent, but for `mod f`, it's `mod f` itself, but we're
3032 // interested in its parent.
3133 if ctx. original_token . kind ( ) == SyntaxKind :: IDENT {
3234 if let Some ( module) = ctx. original_token . ancestors ( ) . nth ( 1 ) . and_then ( ast:: Module :: cast) {
0 commit comments