diff options
Diffstat (limited to 'crates/ra_assists/src/lib.rs')
-rw-r--r-- | crates/ra_assists/src/lib.rs | 101 |
1 files changed, 54 insertions, 47 deletions
diff --git a/crates/ra_assists/src/lib.rs b/crates/ra_assists/src/lib.rs index 756acf415..71b017076 100644 --- a/crates/ra_assists/src/lib.rs +++ b/crates/ra_assists/src/lib.rs | |||
@@ -8,6 +8,7 @@ | |||
8 | mod assist_ctx; | 8 | mod assist_ctx; |
9 | mod marks; | 9 | mod marks; |
10 | pub mod ast_editor; | 10 | pub mod ast_editor; |
11 | pub mod ast_builder; | ||
11 | 12 | ||
12 | use itertools::Itertools; | 13 | use itertools::Itertools; |
13 | 14 | ||
@@ -17,6 +18,7 @@ use ra_syntax::{TextRange, TextUnit}; | |||
17 | use ra_text_edit::TextEdit; | 18 | use ra_text_edit::TextEdit; |
18 | 19 | ||
19 | pub(crate) use crate::assist_ctx::{Assist, AssistCtx}; | 20 | pub(crate) use crate::assist_ctx::{Assist, AssistCtx}; |
21 | pub use crate::assists::auto_import::auto_import_text_edit; | ||
20 | 22 | ||
21 | /// Unique identifier of the assist, should not be shown to the user | 23 | /// Unique identifier of the assist, should not be shown to the user |
22 | /// directly. | 24 | /// directly. |
@@ -46,7 +48,7 @@ where | |||
46 | H: HirDatabase + 'static, | 48 | H: HirDatabase + 'static, |
47 | { | 49 | { |
48 | AssistCtx::with_ctx(db, range, false, |ctx| { | 50 | AssistCtx::with_ctx(db, range, false, |ctx| { |
49 | all_assists() | 51 | assists::all() |
50 | .iter() | 52 | .iter() |
51 | .filter_map(|f| f(ctx.clone())) | 53 | .filter_map(|f| f(ctx.clone())) |
52 | .map(|a| match a { | 54 | .map(|a| match a { |
@@ -68,7 +70,7 @@ where | |||
68 | use std::cmp::Ordering; | 70 | use std::cmp::Ordering; |
69 | 71 | ||
70 | AssistCtx::with_ctx(db, range, true, |ctx| { | 72 | AssistCtx::with_ctx(db, range, true, |ctx| { |
71 | let mut a = all_assists() | 73 | let mut a = assists::all() |
72 | .iter() | 74 | .iter() |
73 | .filter_map(|f| f(ctx.clone())) | 75 | .filter_map(|f| f(ctx.clone())) |
74 | .map(|a| match a { | 76 | .map(|a| match a { |
@@ -86,51 +88,56 @@ where | |||
86 | }) | 88 | }) |
87 | } | 89 | } |
88 | 90 | ||
89 | mod add_derive; | 91 | mod assists { |
90 | mod add_explicit_type; | 92 | use crate::{Assist, AssistCtx}; |
91 | mod add_impl; | 93 | use hir::db::HirDatabase; |
92 | mod flip_comma; | 94 | |
93 | mod flip_binexpr; | 95 | mod add_derive; |
94 | mod change_visibility; | 96 | mod add_explicit_type; |
95 | mod fill_match_arms; | 97 | mod add_impl; |
96 | mod merge_match_arms; | 98 | mod flip_comma; |
97 | mod introduce_variable; | 99 | mod flip_binexpr; |
98 | mod inline_local_variable; | 100 | mod change_visibility; |
99 | mod raw_string; | 101 | mod fill_match_arms; |
100 | mod replace_if_let_with_match; | 102 | mod merge_match_arms; |
101 | mod split_import; | 103 | mod introduce_variable; |
102 | mod remove_dbg; | 104 | mod inline_local_variable; |
103 | pub mod auto_import; | 105 | mod raw_string; |
104 | mod add_missing_impl_members; | 106 | mod replace_if_let_with_match; |
105 | mod move_guard; | 107 | mod split_import; |
106 | mod move_bounds; | 108 | mod remove_dbg; |
107 | 109 | pub(crate) mod auto_import; | |
108 | fn all_assists<DB: HirDatabase>() -> &'static [fn(AssistCtx<DB>) -> Option<Assist>] { | 110 | mod add_missing_impl_members; |
109 | &[ | 111 | mod move_guard; |
110 | add_derive::add_derive, | 112 | mod move_bounds; |
111 | add_explicit_type::add_explicit_type, | 113 | |
112 | add_impl::add_impl, | 114 | pub(crate) fn all<DB: HirDatabase>() -> &'static [fn(AssistCtx<DB>) -> Option<Assist>] { |
113 | change_visibility::change_visibility, | 115 | &[ |
114 | fill_match_arms::fill_match_arms, | 116 | add_derive::add_derive, |
115 | merge_match_arms::merge_match_arms, | 117 | add_explicit_type::add_explicit_type, |
116 | flip_comma::flip_comma, | 118 | add_impl::add_impl, |
117 | flip_binexpr::flip_binexpr, | 119 | change_visibility::change_visibility, |
118 | introduce_variable::introduce_variable, | 120 | fill_match_arms::fill_match_arms, |
119 | replace_if_let_with_match::replace_if_let_with_match, | 121 | merge_match_arms::merge_match_arms, |
120 | split_import::split_import, | 122 | flip_comma::flip_comma, |
121 | remove_dbg::remove_dbg, | 123 | flip_binexpr::flip_binexpr, |
122 | auto_import::auto_import, | 124 | introduce_variable::introduce_variable, |
123 | add_missing_impl_members::add_missing_impl_members, | 125 | replace_if_let_with_match::replace_if_let_with_match, |
124 | add_missing_impl_members::add_missing_default_members, | 126 | split_import::split_import, |
125 | inline_local_variable::inline_local_varialbe, | 127 | remove_dbg::remove_dbg, |
126 | move_guard::move_guard_to_arm_body, | 128 | auto_import::auto_import, |
127 | move_guard::move_arm_cond_to_match_guard, | 129 | add_missing_impl_members::add_missing_impl_members, |
128 | move_bounds::move_bounds_to_where_clause, | 130 | add_missing_impl_members::add_missing_default_members, |
129 | raw_string::add_hash, | 131 | inline_local_variable::inline_local_varialbe, |
130 | raw_string::make_raw_string, | 132 | move_guard::move_guard_to_arm_body, |
131 | raw_string::make_usual_string, | 133 | move_guard::move_arm_cond_to_match_guard, |
132 | raw_string::remove_hash, | 134 | move_bounds::move_bounds_to_where_clause, |
133 | ] | 135 | raw_string::add_hash, |
136 | raw_string::make_raw_string, | ||
137 | raw_string::make_usual_string, | ||
138 | raw_string::remove_hash, | ||
139 | ] | ||
140 | } | ||
134 | } | 141 | } |
135 | 142 | ||
136 | #[cfg(test)] | 143 | #[cfg(test)] |