@@ -9,20 +9,16 @@ use ra_syntax::{
99
1010use crate :: {
1111 db:: RootDatabase ,
12- input:: { SourceRootId } ,
1312 completion:: CompletionItem ,
14- descriptors:: module:: { ModuleId , ModuleTree } ,
13+ descriptors:: module:: { ModuleDescriptor } ,
1514 descriptors:: function:: FnScopes ,
16- descriptors:: DescriptorDatabase ,
1715 Cancelable
1816} ;
1917
2018pub ( super ) fn completions (
2119 acc : & mut Vec < CompletionItem > ,
2220 db : & RootDatabase ,
23- source_root_id : SourceRootId ,
24- module_tree : & ModuleTree ,
25- module_id : ModuleId ,
21+ module : & ModuleDescriptor ,
2622 file : & SourceFileNode ,
2723 name_ref : ast:: NameRef ,
2824) -> Cancelable < ( ) > {
@@ -40,7 +36,7 @@ pub(super) fn completions(
4036 complete_expr_snippets ( acc) ;
4137 }
4238
43- let module_scope = db . module_scope ( source_root_id , module_id ) ?;
39+ let module_scope = module . scope ( db ) ?;
4440 acc. extend (
4541 module_scope
4642 . entries ( )
@@ -56,9 +52,7 @@ pub(super) fn completions(
5652 } ) ,
5753 ) ;
5854 }
59- NameRefKind :: CratePath ( path) => {
60- complete_path ( acc, db, source_root_id, module_tree, module_id, path) ?
61- }
55+ NameRefKind :: CratePath ( path) => complete_path ( acc, db, module, path) ?,
6256 NameRefKind :: BareIdentInMod => {
6357 let name_range = name_ref. syntax ( ) . range ( ) ;
6458 let top_node = name_ref
@@ -171,16 +165,14 @@ fn complete_fn(name_ref: ast::NameRef, scopes: &FnScopes, acc: &mut Vec<Completi
171165fn complete_path (
172166 acc : & mut Vec < CompletionItem > ,
173167 db : & RootDatabase ,
174- source_root_id : SourceRootId ,
175- module_tree : & ModuleTree ,
176- module_id : ModuleId ,
168+ module : & ModuleDescriptor ,
177169 crate_path : Vec < ast:: NameRef > ,
178170) -> Cancelable < ( ) > {
179- let target_module_id = match find_target_module ( module_tree , module_id , crate_path) {
171+ let target_module = match find_target_module ( module , crate_path) {
180172 None => return Ok ( ( ) ) ,
181173 Some ( it) => it,
182174 } ;
183- let module_scope = db . module_scope ( source_root_id , target_module_id ) ?;
175+ let module_scope = target_module . scope ( db ) ?;
184176 let completions = module_scope. entries ( ) . iter ( ) . map ( |entry| CompletionItem {
185177 label : entry. name ( ) . to_string ( ) ,
186178 lookup : None ,
@@ -191,14 +183,13 @@ fn complete_path(
191183}
192184
193185fn find_target_module (
194- module_tree : & ModuleTree ,
195- module_id : ModuleId ,
186+ module : & ModuleDescriptor ,
196187 mut crate_path : Vec < ast:: NameRef > ,
197- ) -> Option < ModuleId > {
188+ ) -> Option < ModuleDescriptor > {
198189 crate_path. pop ( ) ;
199- let mut target_module = module_id . root ( & module_tree ) ;
190+ let mut target_module = module . crate_root ( ) ;
200191 for name in crate_path {
201- target_module = target_module. child ( module_tree , name. text ( ) . as_str ( ) ) ?;
192+ target_module = target_module. child ( name. text ( ) . as_str ( ) ) ?;
202193 }
203194 Some ( target_module)
204195}
0 commit comments