mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 08:13:41 +00:00
One pub function less is good!
This commit is contained in:
parent
762915826a
commit
7702f690a9
@ -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)
|
||||
}
|
||||
}?;
|
||||
|
@ -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 {
|
||||
|
@ -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 })
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user