diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_hir/src/from_source.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir_def/src/nameres.rs | 20 |
2 files changed, 2 insertions, 20 deletions
diff --git a/crates/ra_hir/src/from_source.rs b/crates/ra_hir/src/from_source.rs index 94a5e0b0d..67b127ba5 100644 --- a/crates/ra_hir/src/from_source.rs +++ b/crates/ra_hir/src/from_source.rs | |||
@@ -238,7 +238,7 @@ impl Module { | |||
238 | _ => { | 238 | _ => { |
239 | let src_parent = InFile { | 239 | let src_parent = InFile { |
240 | file_id: src.file_id, | 240 | file_id: src.file_id, |
241 | value: ModuleSource::new(db, Some(src.file_id.original_file(db)), None), | 241 | value: ModuleSource::from_file_id(db, src.file_id.original_file(db)), |
242 | }; | 242 | }; |
243 | Module::from_definition(db, src_parent) | 243 | Module::from_definition(db, src_parent) |
244 | } | 244 | } |
diff --git a/crates/ra_hir_def/src/nameres.rs b/crates/ra_hir_def/src/nameres.rs index e356515cb..ce318571c 100644 --- a/crates/ra_hir_def/src/nameres.rs +++ b/crates/ra_hir_def/src/nameres.rs | |||
@@ -356,6 +356,7 @@ impl ModuleData { | |||
356 | } | 356 | } |
357 | } | 357 | } |
358 | 358 | ||
359 | #[derive(Debug, Clone, PartialEq, Eq)] | ||
359 | pub enum ModuleSource { | 360 | pub enum ModuleSource { |
360 | SourceFile(ast::SourceFile), | 361 | SourceFile(ast::SourceFile), |
361 | Module(ast::Module), | 362 | Module(ast::Module), |
@@ -363,25 +364,6 @@ pub enum ModuleSource { | |||
363 | } | 364 | } |
364 | 365 | ||
365 | impl ModuleSource { | 366 | impl ModuleSource { |
366 | pub fn new( | ||
367 | db: &impl DefDatabase, | ||
368 | file_id: Option<FileId>, | ||
369 | decl_id: Option<AstId<ast::Module>>, | ||
370 | ) -> ModuleSource { | ||
371 | match (file_id, decl_id) { | ||
372 | (Some(file_id), _) => { | ||
373 | let source_file = db.parse(file_id).tree(); | ||
374 | ModuleSource::SourceFile(source_file) | ||
375 | } | ||
376 | (None, Some(item_id)) => { | ||
377 | let module = item_id.to_node(db); | ||
378 | assert!(module.item_list().is_some(), "expected inline module"); | ||
379 | ModuleSource::Module(module) | ||
380 | } | ||
381 | (None, None) => panic!(), | ||
382 | } | ||
383 | } | ||
384 | |||
385 | // FIXME: this methods do not belong here | 367 | // FIXME: this methods do not belong here |
386 | pub fn from_position(db: &impl DefDatabase, position: FilePosition) -> ModuleSource { | 368 | pub fn from_position(db: &impl DefDatabase, position: FilePosition) -> ModuleSource { |
387 | let parse = db.parse(position.file_id); | 369 | let parse = db.parse(position.file_id); |