aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists/src/assist_ctx.rs
diff options
context:
space:
mode:
authorrobojumper <[email protected]>2019-02-08 21:43:13 +0000
committerrobojumper <[email protected]>2019-02-08 21:43:13 +0000
commita3622eb629bf7acea933d956f8cee902ae357fca (patch)
treee09c517a22f7cf4229c8d4a306f68d9f3940adec /crates/ra_assists/src/assist_ctx.rs
parent12e3b4c70b5ef23b2fdfc197296d483680e125f9 (diff)
Add some assist ranges
Diffstat (limited to 'crates/ra_assists/src/assist_ctx.rs')
-rw-r--r--crates/ra_assists/src/assist_ctx.rs13
1 files changed, 11 insertions, 2 deletions
diff --git a/crates/ra_assists/src/assist_ctx.rs b/crates/ra_assists/src/assist_ctx.rs
index 0bf640241..41c8ac2f6 100644
--- a/crates/ra_assists/src/assist_ctx.rs
+++ b/crates/ra_assists/src/assist_ctx.rs
@@ -16,7 +16,7 @@ pub(crate) enum Assist {
16 16
17/// `AssistCtx` allows to apply an assist or check if it could be applied. 17/// `AssistCtx` allows to apply an assist or check if it could be applied.
18/// 18///
19/// Assists use a somewhat overengineered approach, given the current needs. The 19/// Assists use a somewhat over-engineered approach, given the current needs. The
20/// assists workflow consists of two phases. In the first phase, a user asks for 20/// assists workflow consists of two phases. In the first phase, a user asks for
21/// the list of available assists. In the second phase, the user picks a 21/// the list of available assists. In the second phase, the user picks a
22/// particular assist and it gets applied. 22/// particular assist and it gets applied.
@@ -106,6 +106,7 @@ impl<'a, DB: HirDatabase> AssistCtx<'a, DB> {
106pub(crate) struct AssistBuilder { 106pub(crate) struct AssistBuilder {
107 edit: TextEditBuilder, 107 edit: TextEditBuilder,
108 cursor_position: Option<TextUnit>, 108 cursor_position: Option<TextUnit>,
109 target: Option<TextRange>,
109} 110}
110 111
111impl AssistBuilder { 112impl AssistBuilder {
@@ -138,7 +139,15 @@ impl AssistBuilder {
138 self.cursor_position = Some(offset) 139 self.cursor_position = Some(offset)
139 } 140 }
140 141
142 pub(crate) fn target(&mut self, target: TextRange) {
143 self.target = Some(target)
144 }
145
141 fn build(self) -> AssistAction { 146 fn build(self) -> AssistAction {
142 AssistAction { edit: self.edit.finish(), cursor_position: self.cursor_position } 147 AssistAction {
148 edit: self.edit.finish(),
149 cursor_position: self.cursor_position,
150 target: self.target,
151 }
143 } 152 }
144} 153}