One pub function less is good!

This commit is contained in:
ice1000 2019-12-05 08:28:31 -05:00
parent 762915826a
commit 7702f690a9
3 changed files with 7 additions and 12 deletions

View File

@ -235,11 +235,10 @@ impl Module {
let src_parent = InFile { file_id: src.file_id, value: parent_declaration };
Module::from_declaration(db, src_parent)
}
_ => {
let src_parent = InFile {
file_id: src.file_id,
value: ModuleSource::from_file_id(db, src.file_id.original_file(db)),
};
None => {
let source_file = db.parse(src.file_id.original_file(db)).tree();
let src_parent =
InFile { file_id: src.file_id, value: ModuleSource::SourceFile(source_file) };
Module::from_definition(db, src_parent)
}
}?;

View File

@ -390,11 +390,6 @@ impl ModuleSource {
ModuleSource::SourceFile(source_file)
}
}
pub fn from_file_id(db: &impl DefDatabase, file_id: FileId) -> ModuleSource {
let source_file = db.parse(file_id).tree();
ModuleSource::SourceFile(source_file)
}
}
mod diagnostics {

View File

@ -1,6 +1,6 @@
//! FIXME: write short doc here
use ra_db::{CrateId, FileId, FilePosition};
use ra_db::{CrateId, FileId, FilePosition, SourceDatabase};
use crate::{db::RootDatabase, NavigationTarget};
@ -21,7 +21,8 @@ pub(crate) fn parent_module(db: &RootDatabase, position: FilePosition) -> Vec<Na
/// Returns `Vec` for the same reason as `parent_module`
pub(crate) fn crate_for(db: &RootDatabase, file_id: FileId) -> Vec<CrateId> {
let src = hir::ModuleSource::from_file_id(db, file_id);
let source_file = db.parse(file_id).tree();
let src = hir::ModuleSource::SourceFile(source_file);
let module =
match hir::Module::from_definition(db, hir::InFile { file_id: file_id.into(), value: src })
{