diff options
author | Aleksey Kladov <[email protected]> | 2019-01-01 20:21:16 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-01-01 21:09:54 +0000 |
commit | 37ed2f35badfb41cd6c50ef04d6fd6a6ce67e0d1 (patch) | |
tree | 8c20a12837045e81f2cec18535a6883f6619939e /crates/ra_hir/src/module/nameres.rs | |
parent | 9c65e618498596a5dc75efe0814a5542c54d54d8 (diff) |
rename MFileId -> HirFileId
Diffstat (limited to 'crates/ra_hir/src/module/nameres.rs')
-rw-r--r-- | crates/ra_hir/src/module/nameres.rs | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/crates/ra_hir/src/module/nameres.rs b/crates/ra_hir/src/module/nameres.rs index 27a76a293..cc60ba077 100644 --- a/crates/ra_hir/src/module/nameres.rs +++ b/crates/ra_hir/src/module/nameres.rs | |||
@@ -25,7 +25,7 @@ use ra_syntax::{ | |||
25 | use ra_db::SourceRootId; | 25 | use ra_db::SourceRootId; |
26 | 26 | ||
27 | use crate::{ | 27 | use crate::{ |
28 | Cancelable, MFileId, FileId, | 28 | Cancelable, HirFileId, FileId, |
29 | DefId, DefLoc, DefKind, | 29 | DefId, DefLoc, DefKind, |
30 | SourceItemId, SourceFileItemId, SourceFileItems, | 30 | SourceItemId, SourceFileItemId, SourceFileItems, |
31 | Path, PathKind, | 31 | Path, PathKind, |
@@ -95,9 +95,11 @@ pub struct NamedImport { | |||
95 | } | 95 | } |
96 | 96 | ||
97 | impl NamedImport { | 97 | impl NamedImport { |
98 | // FIXME: this is only here for one use-case in completion. Seems like a | ||
99 | // pretty gross special case. | ||
98 | pub fn range(&self, db: &impl HirDatabase, file_id: FileId) -> TextRange { | 100 | pub fn range(&self, db: &impl HirDatabase, file_id: FileId) -> TextRange { |
99 | let source_item_id = SourceItemId { | 101 | let source_item_id = SourceItemId { |
100 | mfile_id: file_id.into(), | 102 | file_id: file_id.into(), |
101 | item_id: Some(self.file_item_id), | 103 | item_id: Some(self.file_item_id), |
102 | }; | 104 | }; |
103 | let syntax = db.file_item(source_item_id); | 105 | let syntax = db.file_item(source_item_id); |
@@ -211,25 +213,25 @@ impl<T> PerNs<T> { | |||
211 | impl InputModuleItems { | 213 | impl InputModuleItems { |
212 | pub(crate) fn add_item( | 214 | pub(crate) fn add_item( |
213 | &mut self, | 215 | &mut self, |
214 | mfile_id: MFileId, | 216 | file_id: HirFileId, |
215 | file_items: &SourceFileItems, | 217 | file_items: &SourceFileItems, |
216 | item: ast::ModuleItem, | 218 | item: ast::ModuleItem, |
217 | ) -> Option<()> { | 219 | ) -> Option<()> { |
218 | match item { | 220 | match item { |
219 | ast::ModuleItem::StructDef(it) => { | 221 | ast::ModuleItem::StructDef(it) => { |
220 | self.items.push(ModuleItem::new(mfile_id, file_items, it)?) | 222 | self.items.push(ModuleItem::new(file_id, file_items, it)?) |
221 | } | 223 | } |
222 | ast::ModuleItem::EnumDef(it) => { | 224 | ast::ModuleItem::EnumDef(it) => { |
223 | self.items.push(ModuleItem::new(mfile_id, file_items, it)?) | 225 | self.items.push(ModuleItem::new(file_id, file_items, it)?) |
224 | } | 226 | } |
225 | ast::ModuleItem::FnDef(it) => { | 227 | ast::ModuleItem::FnDef(it) => { |
226 | self.items.push(ModuleItem::new(mfile_id, file_items, it)?) | 228 | self.items.push(ModuleItem::new(file_id, file_items, it)?) |
227 | } | 229 | } |
228 | ast::ModuleItem::TraitDef(it) => { | 230 | ast::ModuleItem::TraitDef(it) => { |
229 | self.items.push(ModuleItem::new(mfile_id, file_items, it)?) | 231 | self.items.push(ModuleItem::new(file_id, file_items, it)?) |
230 | } | 232 | } |
231 | ast::ModuleItem::TypeDef(it) => { | 233 | ast::ModuleItem::TypeDef(it) => { |
232 | self.items.push(ModuleItem::new(mfile_id, file_items, it)?) | 234 | self.items.push(ModuleItem::new(file_id, file_items, it)?) |
233 | } | 235 | } |
234 | ast::ModuleItem::ImplItem(_) => { | 236 | ast::ModuleItem::ImplItem(_) => { |
235 | // impls don't define items | 237 | // impls don't define items |
@@ -239,13 +241,13 @@ impl InputModuleItems { | |||
239 | // TODO | 241 | // TODO |
240 | } | 242 | } |
241 | ast::ModuleItem::ConstDef(it) => { | 243 | ast::ModuleItem::ConstDef(it) => { |
242 | self.items.push(ModuleItem::new(mfile_id, file_items, it)?) | 244 | self.items.push(ModuleItem::new(file_id, file_items, it)?) |
243 | } | 245 | } |
244 | ast::ModuleItem::StaticDef(it) => { | 246 | ast::ModuleItem::StaticDef(it) => { |
245 | self.items.push(ModuleItem::new(mfile_id, file_items, it)?) | 247 | self.items.push(ModuleItem::new(file_id, file_items, it)?) |
246 | } | 248 | } |
247 | ast::ModuleItem::Module(it) => { | 249 | ast::ModuleItem::Module(it) => { |
248 | self.items.push(ModuleItem::new(mfile_id, file_items, it)?) | 250 | self.items.push(ModuleItem::new(file_id, file_items, it)?) |
249 | } | 251 | } |
250 | } | 252 | } |
251 | Some(()) | 253 | Some(()) |
@@ -269,7 +271,7 @@ impl InputModuleItems { | |||
269 | 271 | ||
270 | impl ModuleItem { | 272 | impl ModuleItem { |
271 | fn new<'a>( | 273 | fn new<'a>( |
272 | mfile_id: MFileId, | 274 | file_id: HirFileId, |
273 | file_items: &SourceFileItems, | 275 | file_items: &SourceFileItems, |
274 | item: impl ast::NameOwner<'a>, | 276 | item: impl ast::NameOwner<'a>, |
275 | ) -> Option<ModuleItem> { | 277 | ) -> Option<ModuleItem> { |
@@ -277,7 +279,7 @@ impl ModuleItem { | |||
277 | let kind = item.syntax().kind(); | 279 | let kind = item.syntax().kind(); |
278 | let vis = Vis::Other; | 280 | let vis = Vis::Other; |
279 | let item_id = Some(file_items.id_of_unchecked(item.syntax())); | 281 | let item_id = Some(file_items.id_of_unchecked(item.syntax())); |
280 | let id = SourceItemId { mfile_id, item_id }; | 282 | let id = SourceItemId { file_id, item_id }; |
281 | let res = ModuleItem { | 283 | let res = ModuleItem { |
282 | id, | 284 | id, |
283 | name, | 285 | name, |
@@ -339,7 +341,8 @@ where | |||
339 | let root_id = module_id.crate_root(&self.module_tree); | 341 | let root_id = module_id.crate_root(&self.module_tree); |
340 | let file_id = root_id.source(&self.module_tree).file_id(); | 342 | let file_id = root_id.source(&self.module_tree).file_id(); |
341 | let crate_graph = self.db.crate_graph(); | 343 | let crate_graph = self.db.crate_graph(); |
342 | if let Some(crate_id) = crate_graph.crate_id_for_crate_root(file_id) { | 344 | if let Some(crate_id) = crate_graph.crate_id_for_crate_root(file_id.as_original_file()) |
345 | { | ||
343 | let krate = Crate::new(crate_id); | 346 | let krate = Crate::new(crate_id); |
344 | for dep in krate.dependencies(self.db) { | 347 | for dep in krate.dependencies(self.db) { |
345 | if let Some(module) = dep.krate.root_module(self.db)? { | 348 | if let Some(module) = dep.krate.root_module(self.db)? { |