diff options
Diffstat (limited to 'crates/ra_assists/src/lib.rs')
-rw-r--r-- | crates/ra_assists/src/lib.rs | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/crates/ra_assists/src/lib.rs b/crates/ra_assists/src/lib.rs index b6dc7cb1b..464bc03dd 100644 --- a/crates/ra_assists/src/lib.rs +++ b/crates/ra_assists/src/lib.rs | |||
@@ -10,8 +10,8 @@ macro_rules! eprintln { | |||
10 | ($($tt:tt)*) => { stdx::eprintln!($($tt)*) }; | 10 | ($($tt:tt)*) => { stdx::eprintln!($($tt)*) }; |
11 | } | 11 | } |
12 | 12 | ||
13 | mod assist_config; | ||
13 | mod assist_context; | 14 | mod assist_context; |
14 | mod marks; | ||
15 | #[cfg(test)] | 15 | #[cfg(test)] |
16 | mod tests; | 16 | mod tests; |
17 | pub mod utils; | 17 | pub mod utils; |
@@ -24,6 +24,8 @@ use ra_syntax::TextRange; | |||
24 | 24 | ||
25 | pub(crate) use crate::assist_context::{AssistContext, Assists}; | 25 | pub(crate) use crate::assist_context::{AssistContext, Assists}; |
26 | 26 | ||
27 | pub use assist_config::AssistConfig; | ||
28 | |||
27 | /// Unique identifier of the assist, should not be shown to the user | 29 | /// Unique identifier of the assist, should not be shown to the user |
28 | /// directly. | 30 | /// directly. |
29 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] | 31 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] |
@@ -54,9 +56,9 @@ impl Assist { | |||
54 | /// | 56 | /// |
55 | /// Assists are returned in the "unresolved" state, that is only labels are | 57 | /// Assists are returned in the "unresolved" state, that is only labels are |
56 | /// returned, without actual edits. | 58 | /// returned, without actual edits. |
57 | pub fn unresolved(db: &RootDatabase, range: FileRange) -> Vec<Assist> { | 59 | pub fn unresolved(db: &RootDatabase, config: &AssistConfig, range: FileRange) -> Vec<Assist> { |
58 | let sema = Semantics::new(db); | 60 | let sema = Semantics::new(db); |
59 | let ctx = AssistContext::new(sema, range); | 61 | let ctx = AssistContext::new(sema, config, range); |
60 | let mut acc = Assists::new_unresolved(&ctx); | 62 | let mut acc = Assists::new_unresolved(&ctx); |
61 | handlers::all().iter().for_each(|handler| { | 63 | handlers::all().iter().for_each(|handler| { |
62 | handler(&mut acc, &ctx); | 64 | handler(&mut acc, &ctx); |
@@ -68,9 +70,13 @@ impl Assist { | |||
68 | /// | 70 | /// |
69 | /// Assists are returned in the "resolved" state, that is with edit fully | 71 | /// Assists are returned in the "resolved" state, that is with edit fully |
70 | /// computed. | 72 | /// computed. |
71 | pub fn resolved(db: &RootDatabase, range: FileRange) -> Vec<ResolvedAssist> { | 73 | pub fn resolved( |
74 | db: &RootDatabase, | ||
75 | config: &AssistConfig, | ||
76 | range: FileRange, | ||
77 | ) -> Vec<ResolvedAssist> { | ||
72 | let sema = Semantics::new(db); | 78 | let sema = Semantics::new(db); |
73 | let ctx = AssistContext::new(sema, range); | 79 | let ctx = AssistContext::new(sema, config, range); |
74 | let mut acc = Assists::new_resolved(&ctx); | 80 | let mut acc = Assists::new_resolved(&ctx); |
75 | handlers::all().iter().for_each(|handler| { | 81 | handlers::all().iter().for_each(|handler| { |
76 | handler(&mut acc, &ctx); | 82 | handler(&mut acc, &ctx); |
@@ -103,12 +109,14 @@ mod handlers { | |||
103 | mod add_impl; | 109 | mod add_impl; |
104 | mod add_missing_impl_members; | 110 | mod add_missing_impl_members; |
105 | mod add_new; | 111 | mod add_new; |
112 | mod add_turbo_fish; | ||
106 | mod apply_demorgan; | 113 | mod apply_demorgan; |
107 | mod auto_import; | 114 | mod auto_import; |
108 | mod change_return_type_to_result; | 115 | mod change_return_type_to_result; |
109 | mod change_visibility; | 116 | mod change_visibility; |
110 | mod early_return; | 117 | mod early_return; |
111 | mod fill_match_arms; | 118 | mod fill_match_arms; |
119 | mod fix_visibility; | ||
112 | mod flip_binexpr; | 120 | mod flip_binexpr; |
113 | mod flip_comma; | 121 | mod flip_comma; |
114 | mod flip_trait_bound; | 122 | mod flip_trait_bound; |
@@ -140,12 +148,14 @@ mod handlers { | |||
140 | add_function::add_function, | 148 | add_function::add_function, |
141 | add_impl::add_impl, | 149 | add_impl::add_impl, |
142 | add_new::add_new, | 150 | add_new::add_new, |
151 | add_turbo_fish::add_turbo_fish, | ||
143 | apply_demorgan::apply_demorgan, | 152 | apply_demorgan::apply_demorgan, |
144 | auto_import::auto_import, | 153 | auto_import::auto_import, |
145 | change_return_type_to_result::change_return_type_to_result, | 154 | change_return_type_to_result::change_return_type_to_result, |
146 | change_visibility::change_visibility, | 155 | change_visibility::change_visibility, |
147 | early_return::convert_to_guarded_return, | 156 | early_return::convert_to_guarded_return, |
148 | fill_match_arms::fill_match_arms, | 157 | fill_match_arms::fill_match_arms, |
158 | fix_visibility::fix_visibility, | ||
149 | flip_binexpr::flip_binexpr, | 159 | flip_binexpr::flip_binexpr, |
150 | flip_comma::flip_comma, | 160 | flip_comma::flip_comma, |
151 | flip_trait_bound::flip_trait_bound, | 161 | flip_trait_bound::flip_trait_bound, |