aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorice1000 <[email protected]>2019-12-03 20:58:38 +0000
committerice1000 <[email protected]>2019-12-04 23:30:42 +0000
commit032eb3d68e07f087ac531d48f956a79948baa4b9 (patch)
tree99489ada57e661205e781832b0beaf3107adfdeb
parent5c5f90ba57c83499a44af33bf8b91b24254fb685 (diff)
Remove almost unused `ModuleSource::new`
-rw-r--r--crates/ra_hir/src/from_source.rs2
-rw-r--r--crates/ra_hir_def/src/nameres.rs20
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)]
359pub enum ModuleSource { 360pub 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
365impl ModuleSource { 366impl 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);