From 7702f690a9592605be71104ec9d0b732af940fcc Mon Sep 17 00:00:00 2001 From: ice1000 Date: Thu, 5 Dec 2019 08:28:31 -0500 Subject: One pub function less is good! --- crates/ra_hir/src/from_source.rs | 9 ++++----- crates/ra_hir_def/src/nameres.rs | 5 ----- crates/ra_ide/src/parent_module.rs | 5 +++-- 3 files changed, 7 insertions(+), 12 deletions(-) (limited to 'crates') diff --git a/crates/ra_hir/src/from_source.rs b/crates/ra_hir/src/from_source.rs index a46bba4f2..18d87f6d7 100644 --- a/crates/ra_hir/src/from_source.rs +++ b/crates/ra_hir/src/from_source.rs @@ -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) } }?; diff --git a/crates/ra_hir_def/src/nameres.rs b/crates/ra_hir_def/src/nameres.rs index 01d67777d..0a2b32bbd 100644 --- a/crates/ra_hir_def/src/nameres.rs +++ b/crates/ra_hir_def/src/nameres.rs @@ -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 { diff --git a/crates/ra_ide/src/parent_module.rs b/crates/ra_ide/src/parent_module.rs index 616d69fce..aef3fa3df 100644 --- a/crates/ra_ide/src/parent_module.rs +++ b/crates/ra_ide/src/parent_module.rs @@ -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 Vec { - 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 }) { -- cgit v1.2.3