diff options
author | Aleksey Kladov <[email protected]> | 2020-05-07 16:09:59 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-05-07 16:18:28 +0100 |
commit | c6b81bc013b5278b917d109b723405e0df413323 (patch) | |
tree | fde5c7d0fe22a474ce3b0527254427f96b3ac8ff /crates/ra_assists/src/assist_context.rs | |
parent | c7e305731c922a2d32eda89ff22cb636059bc4e7 (diff) |
Rename AssitLabel -> Assist
Diffstat (limited to 'crates/ra_assists/src/assist_context.rs')
-rw-r--r-- | crates/ra_assists/src/assist_context.rs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/crates/ra_assists/src/assist_context.rs b/crates/ra_assists/src/assist_context.rs index 203ad1273..81052ab49 100644 --- a/crates/ra_assists/src/assist_context.rs +++ b/crates/ra_assists/src/assist_context.rs | |||
@@ -15,7 +15,7 @@ use ra_syntax::{ | |||
15 | }; | 15 | }; |
16 | use ra_text_edit::TextEditBuilder; | 16 | use ra_text_edit::TextEditBuilder; |
17 | 17 | ||
18 | use crate::{AssistId, AssistLabel, GroupLabel, ResolvedAssist}; | 18 | use crate::{Assist, AssistId, GroupLabel, ResolvedAssist}; |
19 | 19 | ||
20 | /// `AssistContext` allows to apply an assist or check if it could be applied. | 20 | /// `AssistContext` allows to apply an assist or check if it could be applied. |
21 | /// | 21 | /// |
@@ -91,7 +91,7 @@ impl<'a> AssistContext<'a> { | |||
91 | pub(crate) struct Assists { | 91 | pub(crate) struct Assists { |
92 | resolve: bool, | 92 | resolve: bool, |
93 | file: FileId, | 93 | file: FileId, |
94 | buf: Vec<(AssistLabel, Option<SourceChange>)>, | 94 | buf: Vec<(Assist, Option<SourceChange>)>, |
95 | } | 95 | } |
96 | 96 | ||
97 | impl Assists { | 97 | impl Assists { |
@@ -102,7 +102,7 @@ impl Assists { | |||
102 | Assists { resolve: false, file: ctx.frange.file_id, buf: Vec::new() } | 102 | Assists { resolve: false, file: ctx.frange.file_id, buf: Vec::new() } |
103 | } | 103 | } |
104 | 104 | ||
105 | pub(crate) fn finish_unresolved(self) -> Vec<AssistLabel> { | 105 | pub(crate) fn finish_unresolved(self) -> Vec<Assist> { |
106 | assert!(!self.resolve); | 106 | assert!(!self.resolve); |
107 | self.finish() | 107 | self.finish() |
108 | .into_iter() | 108 | .into_iter() |
@@ -117,7 +117,7 @@ impl Assists { | |||
117 | assert!(self.resolve); | 117 | assert!(self.resolve); |
118 | self.finish() | 118 | self.finish() |
119 | .into_iter() | 119 | .into_iter() |
120 | .map(|(label, edit)| ResolvedAssist { label, source_change: edit.unwrap() }) | 120 | .map(|(label, edit)| ResolvedAssist { assist: label, source_change: edit.unwrap() }) |
121 | .collect() | 121 | .collect() |
122 | } | 122 | } |
123 | 123 | ||
@@ -128,7 +128,7 @@ impl Assists { | |||
128 | target: TextRange, | 128 | target: TextRange, |
129 | f: impl FnOnce(&mut AssistBuilder), | 129 | f: impl FnOnce(&mut AssistBuilder), |
130 | ) -> Option<()> { | 130 | ) -> Option<()> { |
131 | let label = AssistLabel::new(id, label.into(), None, target); | 131 | let label = Assist::new(id, label.into(), None, target); |
132 | self.add_impl(label, f) | 132 | self.add_impl(label, f) |
133 | } | 133 | } |
134 | pub(crate) fn add_group( | 134 | pub(crate) fn add_group( |
@@ -139,10 +139,10 @@ impl Assists { | |||
139 | target: TextRange, | 139 | target: TextRange, |
140 | f: impl FnOnce(&mut AssistBuilder), | 140 | f: impl FnOnce(&mut AssistBuilder), |
141 | ) -> Option<()> { | 141 | ) -> Option<()> { |
142 | let label = AssistLabel::new(id, label.into(), Some(group.clone()), target); | 142 | let label = Assist::new(id, label.into(), Some(group.clone()), target); |
143 | self.add_impl(label, f) | 143 | self.add_impl(label, f) |
144 | } | 144 | } |
145 | fn add_impl(&mut self, label: AssistLabel, f: impl FnOnce(&mut AssistBuilder)) -> Option<()> { | 145 | fn add_impl(&mut self, label: Assist, f: impl FnOnce(&mut AssistBuilder)) -> Option<()> { |
146 | let change_label = label.label.clone(); | 146 | let change_label = label.label.clone(); |
147 | let source_change = if self.resolve { | 147 | let source_change = if self.resolve { |
148 | let mut builder = AssistBuilder::new(self.file); | 148 | let mut builder = AssistBuilder::new(self.file); |
@@ -156,7 +156,7 @@ impl Assists { | |||
156 | Some(()) | 156 | Some(()) |
157 | } | 157 | } |
158 | 158 | ||
159 | fn finish(mut self) -> Vec<(AssistLabel, Option<SourceChange>)> { | 159 | fn finish(mut self) -> Vec<(Assist, Option<SourceChange>)> { |
160 | self.buf.sort_by_key(|(label, _edit)| label.target.len()); | 160 | self.buf.sort_by_key(|(label, _edit)| label.target.len()); |
161 | self.buf | 161 | self.buf |
162 | } | 162 | } |