aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorice1000 <[email protected]>2019-12-05 13:28:31 +0000
committerice1000 <[email protected]>2019-12-05 13:28:31 +0000
commit7702f690a9592605be71104ec9d0b732af940fcc (patch)
tree3ba9e21961170598f800ea24ed1f5a1a6b345ffa /crates
parent762915826ac6893036f8b5cd5e63677ed862f6d9 (diff)
One pub function less is good!
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_hir/src/from_source.rs9
-rw-r--r--crates/ra_hir_def/src/nameres.rs5
-rw-r--r--crates/ra_ide/src/parent_module.rs5
3 files changed, 7 insertions, 12 deletions
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 {
235 let src_parent = InFile { file_id: src.file_id, value: parent_declaration }; 235 let src_parent = InFile { file_id: src.file_id, value: parent_declaration };
236 Module::from_declaration(db, src_parent) 236 Module::from_declaration(db, src_parent)
237 } 237 }
238 _ => { 238 None => {
239 let src_parent = InFile { 239 let source_file = db.parse(src.file_id.original_file(db)).tree();
240 file_id: src.file_id, 240 let src_parent =
241 value: ModuleSource::from_file_id(db, src.file_id.original_file(db)), 241 InFile { file_id: src.file_id, value: ModuleSource::SourceFile(source_file) };
242 };
243 Module::from_definition(db, src_parent) 242 Module::from_definition(db, src_parent)
244 } 243 }
245 }?; 244 }?;
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 {
390 ModuleSource::SourceFile(source_file) 390 ModuleSource::SourceFile(source_file)
391 } 391 }
392 } 392 }
393
394 pub fn from_file_id(db: &impl DefDatabase, file_id: FileId) -> ModuleSource {
395 let source_file = db.parse(file_id).tree();
396 ModuleSource::SourceFile(source_file)
397 }
398} 393}
399 394
400mod diagnostics { 395mod 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 @@
1//! FIXME: write short doc here 1//! FIXME: write short doc here
2 2
3use ra_db::{CrateId, FileId, FilePosition}; 3use ra_db::{CrateId, FileId, FilePosition, SourceDatabase};
4 4
5use crate::{db::RootDatabase, NavigationTarget}; 5use crate::{db::RootDatabase, NavigationTarget};
6 6
@@ -21,7 +21,8 @@ pub(crate) fn parent_module(db: &RootDatabase, position: FilePosition) -> Vec<Na
21 21
22/// Returns `Vec` for the same reason as `parent_module` 22/// Returns `Vec` for the same reason as `parent_module`
23pub(crate) fn crate_for(db: &RootDatabase, file_id: FileId) -> Vec<CrateId> { 23pub(crate) fn crate_for(db: &RootDatabase, file_id: FileId) -> Vec<CrateId> {
24 let src = hir::ModuleSource::from_file_id(db, file_id); 24 let source_file = db.parse(file_id).tree();
25 let src = hir::ModuleSource::SourceFile(source_file);
25 let module = 26 let module =
26 match hir::Module::from_definition(db, hir::InFile { file_id: file_id.into(), value: src }) 27 match hir::Module::from_definition(db, hir::InFile { file_id: file_id.into(), value: src })
27 { 28 {