diff options
author | Aleksey Kladov <[email protected]> | 2020-05-05 19:42:52 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-05-05 19:42:52 +0100 |
commit | aee22c73c3cafdb6f4b3f97bc483791d4ed2e902 (patch) | |
tree | 735eef9b6397b68ad7d1297737fdb638941803e8 | |
parent | 6c2414430aca92f95eda9f0238dce8af2de552af (diff) |
Move group_label where it belongs
-rw-r--r-- | crates/ra_assists/src/assist_ctx.rs | 7 | ||||
-rw-r--r-- | crates/ra_assists/src/lib.rs | 6 |
2 files changed, 6 insertions, 7 deletions
diff --git a/crates/ra_assists/src/assist_ctx.rs b/crates/ra_assists/src/assist_ctx.rs index d88ae4413..82f61bc8f 100644 --- a/crates/ra_assists/src/assist_ctx.rs +++ b/crates/ra_assists/src/assist_ctx.rs | |||
@@ -38,8 +38,7 @@ impl AssistInfo { | |||
38 | 38 | ||
39 | pub(crate) fn into_resolved(self) -> Option<ResolvedAssist> { | 39 | pub(crate) fn into_resolved(self) -> Option<ResolvedAssist> { |
40 | let label = self.label; | 40 | let label = self.label; |
41 | let group_label = self.group_label; | 41 | self.action.map(|action| ResolvedAssist { label, action }) |
42 | self.action.map(|action| ResolvedAssist { label, group_label, action }) | ||
43 | } | 42 | } |
44 | } | 43 | } |
45 | 44 | ||
@@ -100,7 +99,7 @@ impl<'a> AssistCtx<'a> { | |||
100 | label: impl Into<String>, | 99 | label: impl Into<String>, |
101 | f: impl FnOnce(&mut ActionBuilder), | 100 | f: impl FnOnce(&mut ActionBuilder), |
102 | ) -> Option<Assist> { | 101 | ) -> Option<Assist> { |
103 | let label = AssistLabel::new(id, label.into()); | 102 | let label = AssistLabel::new(id, label.into(), None); |
104 | 103 | ||
105 | let mut info = AssistInfo::new(label); | 104 | let mut info = AssistInfo::new(label); |
106 | if self.should_compute_edit { | 105 | if self.should_compute_edit { |
@@ -158,7 +157,7 @@ impl<'a> AssistGroup<'a> { | |||
158 | label: impl Into<String>, | 157 | label: impl Into<String>, |
159 | f: impl FnOnce(&mut ActionBuilder), | 158 | f: impl FnOnce(&mut ActionBuilder), |
160 | ) { | 159 | ) { |
161 | let label = AssistLabel::new(id, label.into()); | 160 | let label = AssistLabel::new(id, label.into(), Some(self.group.clone())); |
162 | 161 | ||
163 | let mut info = AssistInfo::new(label).with_group(self.group.clone()); | 162 | let mut info = AssistInfo::new(label).with_group(self.group.clone()); |
164 | if self.ctx.should_compute_edit { | 163 | if self.ctx.should_compute_edit { |
diff --git a/crates/ra_assists/src/lib.rs b/crates/ra_assists/src/lib.rs index 6156f4e2c..1b31d655b 100644 --- a/crates/ra_assists/src/lib.rs +++ b/crates/ra_assists/src/lib.rs | |||
@@ -35,16 +35,17 @@ pub struct AssistLabel { | |||
35 | pub id: AssistId, | 35 | pub id: AssistId, |
36 | /// Short description of the assist, as shown in the UI. | 36 | /// Short description of the assist, as shown in the UI. |
37 | pub label: String, | 37 | pub label: String, |
38 | pub group: Option<GroupLabel>, | ||
38 | } | 39 | } |
39 | 40 | ||
40 | #[derive(Clone, Debug)] | 41 | #[derive(Clone, Debug)] |
41 | pub struct GroupLabel(pub String); | 42 | pub struct GroupLabel(pub String); |
42 | 43 | ||
43 | impl AssistLabel { | 44 | impl AssistLabel { |
44 | pub(crate) fn new(id: AssistId, label: String) -> AssistLabel { | 45 | pub(crate) fn new(id: AssistId, label: String, group: Option<GroupLabel>) -> AssistLabel { |
45 | // FIXME: make fields private, so that this invariant can't be broken | 46 | // FIXME: make fields private, so that this invariant can't be broken |
46 | assert!(label.starts_with(|c: char| c.is_uppercase())); | 47 | assert!(label.starts_with(|c: char| c.is_uppercase())); |
47 | AssistLabel { label, id } | 48 | AssistLabel { id, label, group } |
48 | } | 49 | } |
49 | } | 50 | } |
50 | 51 | ||
@@ -60,7 +61,6 @@ pub struct AssistAction { | |||
60 | #[derive(Debug, Clone)] | 61 | #[derive(Debug, Clone)] |
61 | pub struct ResolvedAssist { | 62 | pub struct ResolvedAssist { |
62 | pub label: AssistLabel, | 63 | pub label: AssistLabel, |
63 | pub group_label: Option<GroupLabel>, | ||
64 | pub action: AssistAction, | 64 | pub action: AssistAction, |
65 | } | 65 | } |
66 | 66 | ||