internal: flatten module hierarchy

It seems that any crate can be made better by flattening the modules
down to a single layer?
This commit is contained in:
Aleksey Kladov 2021-06-14 19:14:34 +03:00
parent 9fb67e7477
commit da534bdd07
3 changed files with 10 additions and 9 deletions

View file

@ -39,6 +39,7 @@ mod matching_brace;
mod move_item; mod move_item;
mod parent_module; mod parent_module;
mod references; mod references;
mod rename;
mod fn_references; mod fn_references;
mod runnables; mod runnables;
mod ssr; mod ssr;
@ -79,7 +80,8 @@ pub use crate::{
markup::Markup, markup::Markup,
move_item::Direction, move_item::Direction,
prime_caches::PrimeCachesProgress, prime_caches::PrimeCachesProgress,
references::{rename::RenameError, ReferenceSearchResult}, references::ReferenceSearchResult,
rename::RenameError,
runnables::{Runnable, RunnableKind, TestId}, runnables::{Runnable, RunnableKind, TestId},
syntax_highlighting::{ syntax_highlighting::{
tags::{Highlight, HlMod, HlMods, HlOperator, HlPunct, HlTag}, tags::{Highlight, HlMod, HlMods, HlOperator, HlPunct, HlTag},
@ -591,14 +593,14 @@ impl Analysis {
position: FilePosition, position: FilePosition,
new_name: &str, new_name: &str,
) -> Cancellable<Result<SourceChange, RenameError>> { ) -> Cancellable<Result<SourceChange, RenameError>> {
self.with_db(|db| references::rename::rename(db, position, new_name)) self.with_db(|db| rename::rename(db, position, new_name))
} }
pub fn prepare_rename( pub fn prepare_rename(
&self, &self,
position: FilePosition, position: FilePosition,
) -> Cancellable<Result<RangeInfo<()>, RenameError>> { ) -> Cancellable<Result<RangeInfo<()>, RenameError>> {
self.with_db(|db| references::rename::prepare_rename(db, position)) self.with_db(|db| rename::prepare_rename(db, position))
} }
pub fn will_rename_file( pub fn will_rename_file(
@ -606,7 +608,7 @@ impl Analysis {
file_id: FileId, file_id: FileId,
new_name_stem: &str, new_name_stem: &str,
) -> Cancellable<Option<SourceChange>> { ) -> Cancellable<Option<SourceChange>> {
self.with_db(|db| references::rename::will_rename_file(db, file_id, new_name_stem)) self.with_db(|db| rename::will_rename_file(db, file_id, new_name_stem))
} }
pub fn structural_search_replace( pub fn structural_search_replace(

View file

@ -9,8 +9,6 @@
//! at the index that the match starts at and its tree parent is //! at the index that the match starts at and its tree parent is
//! resolved to the search element definition, we get a reference. //! resolved to the search element definition, we get a reference.
pub(crate) mod rename;
use hir::{PathResolution, Semantics}; use hir::{PathResolution, Semantics};
use ide_db::{ use ide_db::{
base_db::FileId, base_db::FileId,

View file

@ -1,7 +1,8 @@
//! Renaming functionality //! Renaming functionality.
//! //!
//! All reference and file rename requests go through here where the corresponding [`SourceChange`]s //! This is mostly front-end for [`ide_db::rename`], but it also includes the
//! will be calculated. //! tests. This module also implements a couple of magic tricks, like renaming
//! `self` and to `self` (to switch between associated function and method).
use hir::{AsAssocItem, InFile, Semantics}; use hir::{AsAssocItem, InFile, Semantics};
use ide_db::{ use ide_db::{
base_db::FileId, base_db::FileId,