diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/hir/src/semantics.rs | 2 | ||||
-rw-r--r-- | crates/hir_def/src/adt.rs | 6 | ||||
-rw-r--r-- | crates/hir_def/src/attr.rs | 2 | ||||
-rw-r--r-- | crates/hir_def/src/data.rs | 20 | ||||
-rw-r--r-- | crates/hir_def/src/generics.rs | 14 | ||||
-rw-r--r-- | crates/hir_def/src/item_tree.rs | 42 | ||||
-rw-r--r-- | crates/hir_def/src/nameres/collector.rs | 12 | ||||
-rw-r--r-- | crates/hir_def/src/src.rs | 16 |
8 files changed, 77 insertions, 37 deletions
diff --git a/crates/hir/src/semantics.rs b/crates/hir/src/semantics.rs index e0eb2a66d..15651bb22 100644 --- a/crates/hir/src/semantics.rs +++ b/crates/hir/src/semantics.rs | |||
@@ -574,7 +574,7 @@ impl<'db> SemanticsImpl<'db> { | |||
574 | } | 574 | } |
575 | 575 | ||
576 | fn scope_for_def(&self, def: Trait) -> SemanticsScope<'db> { | 576 | fn scope_for_def(&self, def: Trait) -> SemanticsScope<'db> { |
577 | let file_id = self.db.lookup_intern_trait(def.id).id.file_id; | 577 | let file_id = self.db.lookup_intern_trait(def.id).id.file_id(); |
578 | let resolver = def.id.resolver(self.db.upcast()); | 578 | let resolver = def.id.resolver(self.db.upcast()); |
579 | SemanticsScope { db: self.db, file_id, resolver } | 579 | SemanticsScope { db: self.db, file_id, resolver } |
580 | } | 580 | } |
diff --git a/crates/hir_def/src/adt.rs b/crates/hir_def/src/adt.rs index 1b9bb8235..58e35353b 100644 --- a/crates/hir_def/src/adt.rs +++ b/crates/hir_def/src/adt.rs | |||
@@ -94,7 +94,7 @@ impl StructData { | |||
94 | pub(crate) fn struct_data_query(db: &dyn DefDatabase, id: StructId) -> Arc<StructData> { | 94 | pub(crate) fn struct_data_query(db: &dyn DefDatabase, id: StructId) -> Arc<StructData> { |
95 | let loc = id.lookup(db); | 95 | let loc = id.lookup(db); |
96 | let krate = loc.container.krate; | 96 | let krate = loc.container.krate; |
97 | let item_tree = db.item_tree(loc.id.file_id); | 97 | let item_tree = loc.id.item_tree(db); |
98 | let repr = repr_from_value(db, krate, &item_tree, ModItem::from(loc.id.value).into()); | 98 | let repr = repr_from_value(db, krate, &item_tree, ModItem::from(loc.id.value).into()); |
99 | let cfg_options = db.crate_graph()[loc.container.krate].cfg_options.clone(); | 99 | let cfg_options = db.crate_graph()[loc.container.krate].cfg_options.clone(); |
100 | 100 | ||
@@ -110,7 +110,7 @@ impl StructData { | |||
110 | pub(crate) fn union_data_query(db: &dyn DefDatabase, id: UnionId) -> Arc<StructData> { | 110 | pub(crate) fn union_data_query(db: &dyn DefDatabase, id: UnionId) -> Arc<StructData> { |
111 | let loc = id.lookup(db); | 111 | let loc = id.lookup(db); |
112 | let krate = loc.container.krate; | 112 | let krate = loc.container.krate; |
113 | let item_tree = db.item_tree(loc.id.file_id); | 113 | let item_tree = loc.id.item_tree(db); |
114 | let repr = repr_from_value(db, krate, &item_tree, ModItem::from(loc.id.value).into()); | 114 | let repr = repr_from_value(db, krate, &item_tree, ModItem::from(loc.id.value).into()); |
115 | let cfg_options = db.crate_graph()[loc.container.krate].cfg_options.clone(); | 115 | let cfg_options = db.crate_graph()[loc.container.krate].cfg_options.clone(); |
116 | 116 | ||
@@ -130,7 +130,7 @@ impl EnumData { | |||
130 | pub(crate) fn enum_data_query(db: &dyn DefDatabase, e: EnumId) -> Arc<EnumData> { | 130 | pub(crate) fn enum_data_query(db: &dyn DefDatabase, e: EnumId) -> Arc<EnumData> { |
131 | let loc = e.lookup(db); | 131 | let loc = e.lookup(db); |
132 | let krate = loc.container.krate; | 132 | let krate = loc.container.krate; |
133 | let item_tree = db.item_tree(loc.id.file_id); | 133 | let item_tree = loc.id.item_tree(db); |
134 | let cfg_options = db.crate_graph()[krate].cfg_options.clone(); | 134 | let cfg_options = db.crate_graph()[krate].cfg_options.clone(); |
135 | 135 | ||
136 | let enum_ = &item_tree[loc.id.value]; | 136 | let enum_ = &item_tree[loc.id.value]; |
diff --git a/crates/hir_def/src/attr.rs b/crates/hir_def/src/attr.rs index b7353d868..e4c84afbf 100644 --- a/crates/hir_def/src/attr.rs +++ b/crates/hir_def/src/attr.rs | |||
@@ -530,7 +530,7 @@ where | |||
530 | } | 530 | } |
531 | 531 | ||
532 | fn attrs_from_item_tree<N: ItemTreeNode>(id: ItemTreeId<N>, db: &dyn DefDatabase) -> RawAttrs { | 532 | fn attrs_from_item_tree<N: ItemTreeNode>(id: ItemTreeId<N>, db: &dyn DefDatabase) -> RawAttrs { |
533 | let tree = db.item_tree(id.file_id); | 533 | let tree = id.item_tree(db); |
534 | let mod_item = N::id_to_mod_item(id.value); | 534 | let mod_item = N::id_to_mod_item(id.value); |
535 | tree.raw_attrs(mod_item.into()).clone() | 535 | tree.raw_attrs(mod_item.into()).clone() |
536 | } | 536 | } |
diff --git a/crates/hir_def/src/data.rs b/crates/hir_def/src/data.rs index fefc31129..f1772ea3d 100644 --- a/crates/hir_def/src/data.rs +++ b/crates/hir_def/src/data.rs | |||
@@ -38,7 +38,7 @@ impl FunctionData { | |||
38 | let krate = loc.container.module(db).krate; | 38 | let krate = loc.container.module(db).krate; |
39 | let crate_graph = db.crate_graph(); | 39 | let crate_graph = db.crate_graph(); |
40 | let cfg_options = &crate_graph[krate].cfg_options; | 40 | let cfg_options = &crate_graph[krate].cfg_options; |
41 | let item_tree = db.item_tree(loc.id.file_id); | 41 | let item_tree = loc.id.item_tree(db); |
42 | let func = &item_tree[loc.id.value]; | 42 | let func = &item_tree[loc.id.value]; |
43 | 43 | ||
44 | let enabled_params = func | 44 | let enabled_params = func |
@@ -89,7 +89,7 @@ impl TypeAliasData { | |||
89 | typ: TypeAliasId, | 89 | typ: TypeAliasId, |
90 | ) -> Arc<TypeAliasData> { | 90 | ) -> Arc<TypeAliasData> { |
91 | let loc = typ.lookup(db); | 91 | let loc = typ.lookup(db); |
92 | let item_tree = db.item_tree(loc.id.file_id); | 92 | let item_tree = loc.id.item_tree(db); |
93 | let typ = &item_tree[loc.id.value]; | 93 | let typ = &item_tree[loc.id.value]; |
94 | 94 | ||
95 | Arc::new(TypeAliasData { | 95 | Arc::new(TypeAliasData { |
@@ -115,23 +115,23 @@ pub struct TraitData { | |||
115 | impl TraitData { | 115 | impl TraitData { |
116 | pub(crate) fn trait_data_query(db: &dyn DefDatabase, tr: TraitId) -> Arc<TraitData> { | 116 | pub(crate) fn trait_data_query(db: &dyn DefDatabase, tr: TraitId) -> Arc<TraitData> { |
117 | let tr_loc = tr.lookup(db); | 117 | let tr_loc = tr.lookup(db); |
118 | let item_tree = db.item_tree(tr_loc.id.file_id); | 118 | let item_tree = tr_loc.id.item_tree(db); |
119 | let tr_def = &item_tree[tr_loc.id.value]; | 119 | let tr_def = &item_tree[tr_loc.id.value]; |
120 | let name = tr_def.name.clone(); | 120 | let name = tr_def.name.clone(); |
121 | let is_auto = tr_def.is_auto; | 121 | let is_auto = tr_def.is_auto; |
122 | let is_unsafe = tr_def.is_unsafe; | 122 | let is_unsafe = tr_def.is_unsafe; |
123 | let module_id = tr_loc.container; | 123 | let module_id = tr_loc.container; |
124 | let container = AssocContainerId::TraitId(tr); | 124 | let container = AssocContainerId::TraitId(tr); |
125 | let mut expander = Expander::new(db, tr_loc.id.file_id, module_id); | ||
126 | let visibility = item_tree[tr_def.visibility].clone(); | 125 | let visibility = item_tree[tr_def.visibility].clone(); |
127 | let bounds = tr_def.bounds.clone(); | 126 | let bounds = tr_def.bounds.clone(); |
127 | let mut expander = Expander::new(db, tr_loc.id.file_id(), module_id); | ||
128 | 128 | ||
129 | let items = collect_items( | 129 | let items = collect_items( |
130 | db, | 130 | db, |
131 | module_id, | 131 | module_id, |
132 | &mut expander, | 132 | &mut expander, |
133 | tr_def.items.iter().copied(), | 133 | tr_def.items.iter().copied(), |
134 | tr_loc.id.file_id, | 134 | tr_loc.id.file_id(), |
135 | container, | 135 | container, |
136 | 100, | 136 | 100, |
137 | ); | 137 | ); |
@@ -167,21 +167,21 @@ impl ImplData { | |||
167 | let _p = profile::span("impl_data_query"); | 167 | let _p = profile::span("impl_data_query"); |
168 | let impl_loc = id.lookup(db); | 168 | let impl_loc = id.lookup(db); |
169 | 169 | ||
170 | let item_tree = db.item_tree(impl_loc.id.file_id); | 170 | let item_tree = impl_loc.id.item_tree(db); |
171 | let impl_def = &item_tree[impl_loc.id.value]; | 171 | let impl_def = &item_tree[impl_loc.id.value]; |
172 | let target_trait = impl_def.target_trait.map(|id| item_tree[id].clone()); | 172 | let target_trait = impl_def.target_trait.map(|id| item_tree[id].clone()); |
173 | let target_type = item_tree[impl_def.target_type].clone(); | 173 | let target_type = item_tree[impl_def.target_type].clone(); |
174 | let is_negative = impl_def.is_negative; | 174 | let is_negative = impl_def.is_negative; |
175 | let module_id = impl_loc.container; | 175 | let module_id = impl_loc.container; |
176 | let container = AssocContainerId::ImplId(id); | 176 | let container = AssocContainerId::ImplId(id); |
177 | let mut expander = Expander::new(db, impl_loc.id.file_id, module_id); | 177 | let mut expander = Expander::new(db, impl_loc.id.file_id(), module_id); |
178 | 178 | ||
179 | let items = collect_items( | 179 | let items = collect_items( |
180 | db, | 180 | db, |
181 | module_id, | 181 | module_id, |
182 | &mut expander, | 182 | &mut expander, |
183 | impl_def.items.iter().copied(), | 183 | impl_def.items.iter().copied(), |
184 | impl_loc.id.file_id, | 184 | impl_loc.id.file_id(), |
185 | container, | 185 | container, |
186 | 100, | 186 | 100, |
187 | ); | 187 | ); |
@@ -202,7 +202,7 @@ pub struct ConstData { | |||
202 | impl ConstData { | 202 | impl ConstData { |
203 | pub(crate) fn const_data_query(db: &dyn DefDatabase, konst: ConstId) -> Arc<ConstData> { | 203 | pub(crate) fn const_data_query(db: &dyn DefDatabase, konst: ConstId) -> Arc<ConstData> { |
204 | let loc = konst.lookup(db); | 204 | let loc = konst.lookup(db); |
205 | let item_tree = db.item_tree(loc.id.file_id); | 205 | let item_tree = loc.id.item_tree(db); |
206 | let konst = &item_tree[loc.id.value]; | 206 | let konst = &item_tree[loc.id.value]; |
207 | 207 | ||
208 | Arc::new(ConstData { | 208 | Arc::new(ConstData { |
@@ -225,7 +225,7 @@ pub struct StaticData { | |||
225 | impl StaticData { | 225 | impl StaticData { |
226 | pub(crate) fn static_data_query(db: &dyn DefDatabase, konst: StaticId) -> Arc<StaticData> { | 226 | pub(crate) fn static_data_query(db: &dyn DefDatabase, konst: StaticId) -> Arc<StaticData> { |
227 | let node = konst.lookup(db); | 227 | let node = konst.lookup(db); |
228 | let item_tree = db.item_tree(node.id.file_id); | 228 | let item_tree = node.id.item_tree(db); |
229 | let statik = &item_tree[node.id.value]; | 229 | let statik = &item_tree[node.id.value]; |
230 | 230 | ||
231 | Arc::new(StaticData { | 231 | Arc::new(StaticData { |
diff --git a/crates/hir_def/src/generics.rs b/crates/hir_def/src/generics.rs index a056ab797..7c6cbff11 100644 --- a/crates/hir_def/src/generics.rs +++ b/crates/hir_def/src/generics.rs | |||
@@ -97,43 +97,43 @@ impl GenericParams { | |||
97 | let generics = match def { | 97 | let generics = match def { |
98 | GenericDefId::FunctionId(id) => { | 98 | GenericDefId::FunctionId(id) => { |
99 | let id = id.lookup(db).id; | 99 | let id = id.lookup(db).id; |
100 | let tree = db.item_tree(id.file_id); | 100 | let tree = id.item_tree(db); |
101 | let item = &tree[id.value]; | 101 | let item = &tree[id.value]; |
102 | tree[item.generic_params].clone() | 102 | tree[item.generic_params].clone() |
103 | } | 103 | } |
104 | GenericDefId::AdtId(AdtId::StructId(id)) => { | 104 | GenericDefId::AdtId(AdtId::StructId(id)) => { |
105 | let id = id.lookup(db).id; | 105 | let id = id.lookup(db).id; |
106 | let tree = db.item_tree(id.file_id); | 106 | let tree = id.item_tree(db); |
107 | let item = &tree[id.value]; | 107 | let item = &tree[id.value]; |
108 | tree[item.generic_params].clone() | 108 | tree[item.generic_params].clone() |
109 | } | 109 | } |
110 | GenericDefId::AdtId(AdtId::EnumId(id)) => { | 110 | GenericDefId::AdtId(AdtId::EnumId(id)) => { |
111 | let id = id.lookup(db).id; | 111 | let id = id.lookup(db).id; |
112 | let tree = db.item_tree(id.file_id); | 112 | let tree = id.item_tree(db); |
113 | let item = &tree[id.value]; | 113 | let item = &tree[id.value]; |
114 | tree[item.generic_params].clone() | 114 | tree[item.generic_params].clone() |
115 | } | 115 | } |
116 | GenericDefId::AdtId(AdtId::UnionId(id)) => { | 116 | GenericDefId::AdtId(AdtId::UnionId(id)) => { |
117 | let id = id.lookup(db).id; | 117 | let id = id.lookup(db).id; |
118 | let tree = db.item_tree(id.file_id); | 118 | let tree = id.item_tree(db); |
119 | let item = &tree[id.value]; | 119 | let item = &tree[id.value]; |
120 | tree[item.generic_params].clone() | 120 | tree[item.generic_params].clone() |
121 | } | 121 | } |
122 | GenericDefId::TraitId(id) => { | 122 | GenericDefId::TraitId(id) => { |
123 | let id = id.lookup(db).id; | 123 | let id = id.lookup(db).id; |
124 | let tree = db.item_tree(id.file_id); | 124 | let tree = id.item_tree(db); |
125 | let item = &tree[id.value]; | 125 | let item = &tree[id.value]; |
126 | tree[item.generic_params].clone() | 126 | tree[item.generic_params].clone() |
127 | } | 127 | } |
128 | GenericDefId::TypeAliasId(id) => { | 128 | GenericDefId::TypeAliasId(id) => { |
129 | let id = id.lookup(db).id; | 129 | let id = id.lookup(db).id; |
130 | let tree = db.item_tree(id.file_id); | 130 | let tree = id.item_tree(db); |
131 | let item = &tree[id.value]; | 131 | let item = &tree[id.value]; |
132 | tree[item.generic_params].clone() | 132 | tree[item.generic_params].clone() |
133 | } | 133 | } |
134 | GenericDefId::ImplId(id) => { | 134 | GenericDefId::ImplId(id) => { |
135 | let id = id.lookup(db).id; | 135 | let id = id.lookup(db).id; |
136 | let tree = db.item_tree(id.file_id); | 136 | let tree = id.item_tree(db); |
137 | let item = &tree[id.value]; | 137 | let item = &tree[id.value]; |
138 | tree[item.generic_params].clone() | 138 | tree[item.generic_params].clone() |
139 | } | 139 | } |
diff --git a/crates/hir_def/src/item_tree.rs b/crates/hir_def/src/item_tree.rs index 90df3d929..8383780e0 100644 --- a/crates/hir_def/src/item_tree.rs +++ b/crates/hir_def/src/item_tree.rs | |||
@@ -401,7 +401,47 @@ impl<N: ItemTreeNode> fmt::Debug for FileItemTreeId<N> { | |||
401 | } | 401 | } |
402 | } | 402 | } |
403 | 403 | ||
404 | pub type ItemTreeId<N> = InFile<FileItemTreeId<N>>; | 404 | #[derive(Debug)] |
405 | pub struct ItemTreeId<N: ItemTreeNode> { | ||
406 | file: HirFileId, | ||
407 | pub value: FileItemTreeId<N>, | ||
408 | } | ||
409 | |||
410 | impl<N: ItemTreeNode> ItemTreeId<N> { | ||
411 | pub fn new(file: HirFileId, idx: FileItemTreeId<N>) -> Self { | ||
412 | Self { file, value: idx } | ||
413 | } | ||
414 | |||
415 | pub fn file_id(self) -> HirFileId { | ||
416 | self.file | ||
417 | } | ||
418 | |||
419 | pub fn item_tree(self, db: &dyn DefDatabase) -> Arc<ItemTree> { | ||
420 | db.item_tree(self.file) | ||
421 | } | ||
422 | } | ||
423 | |||
424 | impl<N: ItemTreeNode> Copy for ItemTreeId<N> {} | ||
425 | impl<N: ItemTreeNode> Clone for ItemTreeId<N> { | ||
426 | fn clone(&self) -> Self { | ||
427 | *self | ||
428 | } | ||
429 | } | ||
430 | |||
431 | impl<N: ItemTreeNode> PartialEq for ItemTreeId<N> { | ||
432 | fn eq(&self, other: &Self) -> bool { | ||
433 | self.file == other.file && self.value == other.value | ||
434 | } | ||
435 | } | ||
436 | |||
437 | impl<N: ItemTreeNode> Eq for ItemTreeId<N> {} | ||
438 | |||
439 | impl<N: ItemTreeNode> Hash for ItemTreeId<N> { | ||
440 | fn hash<H: Hasher>(&self, state: &mut H) { | ||
441 | self.file.hash(state); | ||
442 | self.value.hash(state); | ||
443 | } | ||
444 | } | ||
405 | 445 | ||
406 | macro_rules! mod_items { | 446 | macro_rules! mod_items { |
407 | ( $( $typ:ident in $fld:ident -> $ast:ty ),+ $(,)? ) => { | 447 | ( $( $typ:ident in $fld:ident -> $ast:ty ),+ $(,)? ) => { |
diff --git a/crates/hir_def/src/nameres/collector.rs b/crates/hir_def/src/nameres/collector.rs index b5ae5a9e4..7ca4299b9 100644 --- a/crates/hir_def/src/nameres/collector.rs +++ b/crates/hir_def/src/nameres/collector.rs | |||
@@ -951,21 +951,21 @@ impl DefCollector<'_> { | |||
951 | let mut diagnosed_extern_crates = FxHashSet::default(); | 951 | let mut diagnosed_extern_crates = FxHashSet::default(); |
952 | for directive in &self.unresolved_imports { | 952 | for directive in &self.unresolved_imports { |
953 | if let ImportSource::ExternCrate(krate) = directive.import.source { | 953 | if let ImportSource::ExternCrate(krate) = directive.import.source { |
954 | let item_tree = self.db.item_tree(krate.file_id); | 954 | let item_tree = krate.item_tree(self.db); |
955 | let extern_crate = &item_tree[krate.value]; | 955 | let extern_crate = &item_tree[krate.value]; |
956 | 956 | ||
957 | diagnosed_extern_crates.insert(extern_crate.name.clone()); | 957 | diagnosed_extern_crates.insert(extern_crate.name.clone()); |
958 | 958 | ||
959 | self.def_map.diagnostics.push(DefDiagnostic::unresolved_extern_crate( | 959 | self.def_map.diagnostics.push(DefDiagnostic::unresolved_extern_crate( |
960 | directive.module_id, | 960 | directive.module_id, |
961 | InFile::new(krate.file_id, extern_crate.ast_id), | 961 | InFile::new(krate.file_id(), extern_crate.ast_id), |
962 | )); | 962 | )); |
963 | } | 963 | } |
964 | } | 964 | } |
965 | 965 | ||
966 | for directive in &self.unresolved_imports { | 966 | for directive in &self.unresolved_imports { |
967 | if let ImportSource::Import(import) = &directive.import.source { | 967 | if let ImportSource::Import(import) = &directive.import.source { |
968 | let item_tree = self.db.item_tree(import.file_id); | 968 | let item_tree = import.item_tree(self.db); |
969 | let import_data = &item_tree[import.value]; | 969 | let import_data = &item_tree[import.value]; |
970 | 970 | ||
971 | match (import_data.path.segments().first(), &import_data.path.kind) { | 971 | match (import_data.path.segments().first(), &import_data.path.kind) { |
@@ -979,7 +979,7 @@ impl DefCollector<'_> { | |||
979 | 979 | ||
980 | self.def_map.diagnostics.push(DefDiagnostic::unresolved_import( | 980 | self.def_map.diagnostics.push(DefDiagnostic::unresolved_import( |
981 | directive.module_id, | 981 | directive.module_id, |
982 | InFile::new(import.file_id, import_data.ast_id), | 982 | InFile::new(import.file_id(), import_data.ast_id), |
983 | import_data.index, | 983 | import_data.index, |
984 | )); | 984 | )); |
985 | } | 985 | } |
@@ -1055,7 +1055,7 @@ impl ModCollector<'_, '_> { | |||
1055 | self.def_collector.db, | 1055 | self.def_collector.db, |
1056 | krate, | 1056 | krate, |
1057 | &self.item_tree, | 1057 | &self.item_tree, |
1058 | InFile::new(self.file_id, import_id), | 1058 | ItemTreeId::new(self.file_id, import_id), |
1059 | ), | 1059 | ), |
1060 | status: PartialResolvedImport::Unresolved, | 1060 | status: PartialResolvedImport::Unresolved, |
1061 | }) | 1061 | }) |
@@ -1067,7 +1067,7 @@ impl ModCollector<'_, '_> { | |||
1067 | self.def_collector.db, | 1067 | self.def_collector.db, |
1068 | krate, | 1068 | krate, |
1069 | &self.item_tree, | 1069 | &self.item_tree, |
1070 | InFile::new(self.file_id, import_id), | 1070 | ItemTreeId::new(self.file_id, import_id), |
1071 | ), | 1071 | ), |
1072 | status: PartialResolvedImport::Unresolved, | 1072 | status: PartialResolvedImport::Unresolved, |
1073 | }) | 1073 | }) |
diff --git a/crates/hir_def/src/src.rs b/crates/hir_def/src/src.rs index 751d4c052..24e57b469 100644 --- a/crates/hir_def/src/src.rs +++ b/crates/hir_def/src/src.rs | |||
@@ -14,12 +14,12 @@ impl<N: ItemTreeNode> HasSource for AssocItemLoc<N> { | |||
14 | type Value = N::Source; | 14 | type Value = N::Source; |
15 | 15 | ||
16 | fn source(&self, db: &dyn DefDatabase) -> InFile<N::Source> { | 16 | fn source(&self, db: &dyn DefDatabase) -> InFile<N::Source> { |
17 | let tree = db.item_tree(self.id.file_id); | 17 | let tree = self.id.item_tree(db); |
18 | let ast_id_map = db.ast_id_map(self.id.file_id); | 18 | let ast_id_map = db.ast_id_map(self.id.file_id()); |
19 | let root = db.parse_or_expand(self.id.file_id).unwrap(); | 19 | let root = db.parse_or_expand(self.id.file_id()).unwrap(); |
20 | let node = &tree[self.id.value]; | 20 | let node = &tree[self.id.value]; |
21 | 21 | ||
22 | InFile::new(self.id.file_id, ast_id_map.get(node.ast_id()).to_node(&root)) | 22 | InFile::new(self.id.file_id(), ast_id_map.get(node.ast_id()).to_node(&root)) |
23 | } | 23 | } |
24 | } | 24 | } |
25 | 25 | ||
@@ -27,12 +27,12 @@ impl<N: ItemTreeNode> HasSource for ItemLoc<N> { | |||
27 | type Value = N::Source; | 27 | type Value = N::Source; |
28 | 28 | ||
29 | fn source(&self, db: &dyn DefDatabase) -> InFile<N::Source> { | 29 | fn source(&self, db: &dyn DefDatabase) -> InFile<N::Source> { |
30 | let tree = db.item_tree(self.id.file_id); | 30 | let tree = self.id.item_tree(db); |
31 | let ast_id_map = db.ast_id_map(self.id.file_id); | 31 | let ast_id_map = db.ast_id_map(self.id.file_id()); |
32 | let root = db.parse_or_expand(self.id.file_id).unwrap(); | 32 | let root = db.parse_or_expand(self.id.file_id()).unwrap(); |
33 | let node = &tree[self.id.value]; | 33 | let node = &tree[self.id.value]; |
34 | 34 | ||
35 | InFile::new(self.id.file_id, ast_id_map.get(node.ast_id()).to_node(&root)) | 35 | InFile::new(self.id.file_id(), ast_id_map.get(node.ast_id()).to_node(&root)) |
36 | } | 36 | } |
37 | } | 37 | } |
38 | 38 | ||