]> git.lizzy.rs Git - rust.git/commitdiff
Move group_label where it belongs
authorAleksey Kladov <aleksey.kladov@gmail.com>
Tue, 5 May 2020 18:42:52 +0000 (20:42 +0200)
committerAleksey Kladov <aleksey.kladov@gmail.com>
Tue, 5 May 2020 18:42:52 +0000 (20:42 +0200)
crates/ra_assists/src/assist_ctx.rs
crates/ra_assists/src/lib.rs

index d88ae441356c600e90187d7d089914e328bd0a4e..82f61bc8f7e336ec87e7d7bd49c7e40236e3e4ec 100644 (file)
@@ -38,8 +38,7 @@ fn with_group(self, group_label: GroupLabel) -> AssistInfo {
 
     pub(crate) fn into_resolved(self) -> Option<ResolvedAssist> {
         let label = self.label;
-        let group_label = self.group_label;
-        self.action.map(|action| ResolvedAssist { label, group_label, action })
+        self.action.map(|action| ResolvedAssist { label, action })
     }
 }
 
@@ -100,7 +99,7 @@ pub(crate) fn add_assist(
         label: impl Into<String>,
         f: impl FnOnce(&mut ActionBuilder),
     ) -> Option<Assist> {
-        let label = AssistLabel::new(id, label.into());
+        let label = AssistLabel::new(id, label.into(), None);
 
         let mut info = AssistInfo::new(label);
         if self.should_compute_edit {
@@ -158,7 +157,7 @@ pub(crate) fn add_assist(
         label: impl Into<String>,
         f: impl FnOnce(&mut ActionBuilder),
     ) {
-        let label = AssistLabel::new(id, label.into());
+        let label = AssistLabel::new(id, label.into(), Some(self.group.clone()));
 
         let mut info = AssistInfo::new(label).with_group(self.group.clone());
         if self.ctx.should_compute_edit {
index 6156f4e2c5084e88835efc895e570b3aff5bb56b..1b31d655b1e64e86e22b1a535bd4b7b3174f89d6 100644 (file)
@@ -35,16 +35,17 @@ pub struct AssistLabel {
     pub id: AssistId,
     /// Short description of the assist, as shown in the UI.
     pub label: String,
+    pub group: Option<GroupLabel>,
 }
 
 #[derive(Clone, Debug)]
 pub struct GroupLabel(pub String);
 
 impl AssistLabel {
-    pub(crate) fn new(id: AssistId, label: String) -> AssistLabel {
+    pub(crate) fn new(id: AssistId, label: String, group: Option<GroupLabel>) -> AssistLabel {
         // FIXME: make fields private, so that this invariant can't be broken
         assert!(label.starts_with(|c: char| c.is_uppercase()));
-        AssistLabel { label, id }
+        AssistLabel { id, label, group }
     }
 }
 
@@ -60,7 +61,6 @@ pub struct AssistAction {
 #[derive(Debug, Clone)]
 pub struct ResolvedAssist {
     pub label: AssistLabel,
-    pub group_label: Option<GroupLabel>,
     pub action: AssistAction,
 }