move assists to subdir

This commit is contained in:
Aleksey Kladov 2019-09-25 14:29:41 +03:00
parent d9b4835625
commit f32081fa18
20 changed files with 54 additions and 48 deletions

View File

@ -17,6 +17,7 @@ use ra_syntax::{TextRange, TextUnit};
use ra_text_edit::TextEdit; use ra_text_edit::TextEdit;
pub(crate) use crate::assist_ctx::{Assist, AssistCtx}; pub(crate) use crate::assist_ctx::{Assist, AssistCtx};
pub use crate::assists::auto_import::auto_import_text_edit;
/// Unique identifier of the assist, should not be shown to the user /// Unique identifier of the assist, should not be shown to the user
/// directly. /// directly.
@ -46,7 +47,7 @@ where
H: HirDatabase + 'static, H: HirDatabase + 'static,
{ {
AssistCtx::with_ctx(db, range, false, |ctx| { AssistCtx::with_ctx(db, range, false, |ctx| {
all_assists() assists::all()
.iter() .iter()
.filter_map(|f| f(ctx.clone())) .filter_map(|f| f(ctx.clone()))
.map(|a| match a { .map(|a| match a {
@ -68,7 +69,7 @@ where
use std::cmp::Ordering; use std::cmp::Ordering;
AssistCtx::with_ctx(db, range, true, |ctx| { AssistCtx::with_ctx(db, range, true, |ctx| {
let mut a = all_assists() let mut a = assists::all()
.iter() .iter()
.filter_map(|f| f(ctx.clone())) .filter_map(|f| f(ctx.clone()))
.map(|a| match a { .map(|a| match a {
@ -86,51 +87,56 @@ where
}) })
} }
mod add_derive; mod assists {
mod add_explicit_type; use crate::{Assist, AssistCtx};
mod add_impl; use hir::db::HirDatabase;
mod flip_comma;
mod flip_binexpr;
mod change_visibility;
mod fill_match_arms;
mod merge_match_arms;
mod introduce_variable;
mod inline_local_variable;
mod raw_string;
mod replace_if_let_with_match;
mod split_import;
mod remove_dbg;
pub mod auto_import;
mod add_missing_impl_members;
mod move_guard;
mod move_bounds;
fn all_assists<DB: HirDatabase>() -> &'static [fn(AssistCtx<DB>) -> Option<Assist>] { mod add_derive;
&[ mod add_explicit_type;
add_derive::add_derive, mod add_impl;
add_explicit_type::add_explicit_type, mod flip_comma;
add_impl::add_impl, mod flip_binexpr;
change_visibility::change_visibility, mod change_visibility;
fill_match_arms::fill_match_arms, mod fill_match_arms;
merge_match_arms::merge_match_arms, mod merge_match_arms;
flip_comma::flip_comma, mod introduce_variable;
flip_binexpr::flip_binexpr, mod inline_local_variable;
introduce_variable::introduce_variable, mod raw_string;
replace_if_let_with_match::replace_if_let_with_match, mod replace_if_let_with_match;
split_import::split_import, mod split_import;
remove_dbg::remove_dbg, mod remove_dbg;
auto_import::auto_import, pub(crate) mod auto_import;
add_missing_impl_members::add_missing_impl_members, mod add_missing_impl_members;
add_missing_impl_members::add_missing_default_members, mod move_guard;
inline_local_variable::inline_local_varialbe, mod move_bounds;
move_guard::move_guard_to_arm_body,
move_guard::move_arm_cond_to_match_guard, pub(crate) fn all<DB: HirDatabase>() -> &'static [fn(AssistCtx<DB>) -> Option<Assist>] {
move_bounds::move_bounds_to_where_clause, &[
raw_string::add_hash, add_derive::add_derive,
raw_string::make_raw_string, add_explicit_type::add_explicit_type,
raw_string::make_usual_string, add_impl::add_impl,
raw_string::remove_hash, change_visibility::change_visibility,
] fill_match_arms::fill_match_arms,
merge_match_arms::merge_match_arms,
flip_comma::flip_comma,
flip_binexpr::flip_binexpr,
introduce_variable::introduce_variable,
replace_if_let_with_match::replace_if_let_with_match,
split_import::split_import,
remove_dbg::remove_dbg,
auto_import::auto_import,
add_missing_impl_members::add_missing_impl_members,
add_missing_impl_members::add_missing_default_members,
inline_local_variable::inline_local_varialbe,
move_guard::move_guard_to_arm_body,
move_guard::move_arm_cond_to_match_guard,
move_bounds::move_bounds_to_where_clause,
raw_string::add_hash,
raw_string::make_raw_string,
raw_string::make_usual_string,
raw_string::remove_hash,
]
}
} }
#[cfg(test)] #[cfg(test)]

View File

@ -1,4 +1,4 @@
use ra_assists::auto_import; use ra_assists::auto_import_text_edit;
use ra_syntax::{ast, AstNode, SmolStr}; use ra_syntax::{ast, AstNode, SmolStr};
use ra_text_edit::TextEditBuilder; use ra_text_edit::TextEditBuilder;
use rustc_hash::FxHashMap; use rustc_hash::FxHashMap;
@ -23,7 +23,7 @@ pub(super) fn complete_scope(acc: &mut Completions, ctx: &CompletionContext) {
let edit = { let edit = {
let mut builder = TextEditBuilder::default(); let mut builder = TextEditBuilder::default();
builder.replace(ctx.source_range(), name.to_string()); builder.replace(ctx.source_range(), name.to_string());
auto_import::auto_import_text_edit( auto_import_text_edit(
&ctx.token.parent(), &ctx.token.parent(),
&ctx.token.parent(), &ctx.token.parent(),
&path, &path,