Remove almost unused ModuleSource::new

This commit is contained in:
ice1000 2019-12-03 15:58:38 -05:00
parent 5c5f90ba57
commit 032eb3d68e
2 changed files with 2 additions and 20 deletions

View File

@ -238,7 +238,7 @@ impl Module {
_ => {
let src_parent = InFile {
file_id: src.file_id,
value: ModuleSource::new(db, Some(src.file_id.original_file(db)), None),
value: ModuleSource::from_file_id(db, src.file_id.original_file(db)),
};
Module::from_definition(db, src_parent)
}

View File

@ -356,6 +356,7 @@ impl ModuleData {
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ModuleSource {
SourceFile(ast::SourceFile),
Module(ast::Module),
@ -363,25 +364,6 @@ pub enum ModuleSource {
}
impl ModuleSource {
pub fn new(
db: &impl DefDatabase,
file_id: Option<FileId>,
decl_id: Option<AstId<ast::Module>>,
) -> ModuleSource {
match (file_id, decl_id) {
(Some(file_id), _) => {
let source_file = db.parse(file_id).tree();
ModuleSource::SourceFile(source_file)
}
(None, Some(item_id)) => {
let module = item_id.to_node(db);
assert!(module.item_list().is_some(), "expected inline module");
ModuleSource::Module(module)
}
(None, None) => panic!(),
}
}
// FIXME: this methods do not belong here
pub fn from_position(db: &impl DefDatabase, position: FilePosition) -> ModuleSource {
let parse = db.parse(position.file_id);