@@ -10,7 +10,7 @@ use crate::{
10
10
body:: Expander ,
11
11
db:: DefDatabase ,
12
12
intern:: Interned ,
13
- item_tree:: { AssocItem , FnFlags , ItemTreeId , ModItem , Param } ,
13
+ item_tree:: { self , AssocItem , FnFlags , ItemTreeId , ModItem , Param } ,
14
14
type_ref:: { TraitRef , TypeBound , TypeRef } ,
15
15
visibility:: RawVisibility ,
16
16
AssocContainerId , AssocItemId , ConstId , ConstLoc , FunctionId , FunctionLoc , HasModule , ImplId ,
@@ -171,7 +171,7 @@ impl TraitData {
171
171
module_id,
172
172
& mut expander,
173
173
tr_def. items . iter ( ) . copied ( ) ,
174
- tr_loc. id . file_id ( ) ,
174
+ tr_loc. id . tree_id ( ) ,
175
175
container,
176
176
100 ,
177
177
) ;
@@ -228,7 +228,7 @@ impl ImplData {
228
228
module_id,
229
229
& mut expander,
230
230
impl_def. items . iter ( ) . copied ( ) ,
231
- impl_loc. id . file_id ( ) ,
231
+ impl_loc. id . tree_id ( ) ,
232
232
container,
233
233
100 ,
234
234
) ;
@@ -290,15 +290,15 @@ fn collect_items(
290
290
module : ModuleId ,
291
291
expander : & mut Expander ,
292
292
assoc_items : impl Iterator < Item = AssocItem > ,
293
- file_id : crate :: HirFileId ,
293
+ tree_id : item_tree :: TreeId ,
294
294
container : AssocContainerId ,
295
295
limit : usize ,
296
296
) -> Vec < ( Name , AssocItemId ) > {
297
297
if limit == 0 {
298
298
return Vec :: new ( ) ;
299
299
}
300
300
301
- let item_tree = db . file_item_tree ( file_id ) ;
301
+ let item_tree = tree_id . item_tree ( db ) ;
302
302
let crate_graph = db. crate_graph ( ) ;
303
303
let cfg_options = & crate_graph[ module. krate ] . cfg_options ;
304
304
@@ -312,7 +312,7 @@ fn collect_items(
312
312
match item {
313
313
AssocItem :: Function ( id) => {
314
314
let item = & item_tree[ id] ;
315
- let def = FunctionLoc { container, id : ItemTreeId :: new ( file_id , id) } . intern ( db) ;
315
+ let def = FunctionLoc { container, id : ItemTreeId :: new ( tree_id , id) } . intern ( db) ;
316
316
items. push ( ( item. name . clone ( ) , def. into ( ) ) ) ;
317
317
}
318
318
AssocItem :: Const ( id) => {
@@ -321,33 +321,34 @@ fn collect_items(
321
321
Some ( name) => name,
322
322
None => continue ,
323
323
} ;
324
- let def = ConstLoc { container, id : ItemTreeId :: new ( file_id , id) } . intern ( db) ;
324
+ let def = ConstLoc { container, id : ItemTreeId :: new ( tree_id , id) } . intern ( db) ;
325
325
items. push ( ( name, def. into ( ) ) ) ;
326
326
}
327
327
AssocItem :: TypeAlias ( id) => {
328
328
let item = & item_tree[ id] ;
329
- let def = TypeAliasLoc { container, id : ItemTreeId :: new ( file_id , id) } . intern ( db) ;
329
+ let def = TypeAliasLoc { container, id : ItemTreeId :: new ( tree_id , id) } . intern ( db) ;
330
330
items. push ( ( item. name . clone ( ) , def. into ( ) ) ) ;
331
331
}
332
332
AssocItem :: MacroCall ( call) => {
333
333
let call = & item_tree[ call] ;
334
- let ast_id_map = db. ast_id_map ( file_id) ;
335
- let root = db. parse_or_expand ( file_id) . unwrap ( ) ;
334
+ let ast_id_map = db. ast_id_map ( tree_id . file_id ( ) ) ;
335
+ let root = db. parse_or_expand ( tree_id . file_id ( ) ) . unwrap ( ) ;
336
336
let call = ast_id_map. get ( call. ast_id ) . to_node ( & root) ;
337
337
let res = expander. enter_expand ( db, call) ;
338
338
339
339
if let Ok ( res) = res {
340
340
if let Some ( ( mark, mac) ) = res. value {
341
341
let src: InFile < ast:: MacroItems > = expander. to_source ( mac) ;
342
- let item_tree = db. file_item_tree ( src. file_id ) ;
342
+ let tree_id = item_tree:: TreeId :: new ( src. file_id , None ) ;
343
+ let item_tree = tree_id. item_tree ( db) ;
343
344
let iter =
344
345
item_tree. top_level_items ( ) . iter ( ) . filter_map ( ModItem :: as_assoc_item) ;
345
346
items. extend ( collect_items (
346
347
db,
347
348
module,
348
349
expander,
349
350
iter,
350
- src . file_id ,
351
+ tree_id ,
351
352
container,
352
353
limit - 1 ,
353
354
) ) ;
0 commit comments