diff options
author | ice1000 <[email protected]> | 2019-12-05 13:28:31 +0000 |
---|---|---|
committer | ice1000 <[email protected]> | 2019-12-05 13:28:31 +0000 |
commit | 7702f690a9592605be71104ec9d0b732af940fcc (patch) | |
tree | 3ba9e21961170598f800ea24ed1f5a1a6b345ffa /crates | |
parent | 762915826ac6893036f8b5cd5e63677ed862f6d9 (diff) |
One pub function less is good!
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_hir/src/from_source.rs | 9 | ||||
-rw-r--r-- | crates/ra_hir_def/src/nameres.rs | 5 | ||||
-rw-r--r-- | crates/ra_ide/src/parent_module.rs | 5 |
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 | ||
400 | mod diagnostics { | 395 | 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 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! FIXME: write short doc here |
2 | 2 | ||
3 | use ra_db::{CrateId, FileId, FilePosition}; | 3 | use ra_db::{CrateId, FileId, FilePosition, SourceDatabase}; |
4 | 4 | ||
5 | use crate::{db::RootDatabase, NavigationTarget}; | 5 | use 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` |
23 | pub(crate) fn crate_for(db: &RootDatabase, file_id: FileId) -> Vec<CrateId> { | 23 | pub(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 | { |