Flip Assist::new arguments

This commit is contained in:
Aleksey Kladov 2020-05-05 20:30:33 +02:00
parent 8803e748a6
commit 13c078db9c
2 changed files with 4 additions and 4 deletions

View file

@ -100,7 +100,7 @@ impl<'a> AssistCtx<'a> {
label: impl Into<String>,
f: impl FnOnce(&mut ActionBuilder),
) -> Option<Assist> {
let label = AssistLabel::new(label.into(), id);
let label = AssistLabel::new(id, label.into());
let mut info = AssistInfo::new(label);
if self.should_compute_edit {
@ -157,7 +157,7 @@ impl<'a> AssistGroup<'a> {
label: impl Into<String>,
f: impl FnOnce(&mut ActionBuilder),
) {
let label = AssistLabel::new(label.into(), id);
let label = AssistLabel::new(id, label.into());
let mut info = AssistInfo::new(label).with_group(GroupLabel(self.group_name.clone()));
if self.ctx.should_compute_edit {

View file

@ -32,16 +32,16 @@ pub struct AssistId(pub &'static str);
#[derive(Debug, Clone)]
pub struct AssistLabel {
pub id: AssistId,
/// Short description of the assist, as shown in the UI.
pub label: String,
pub id: AssistId,
}
#[derive(Clone, Debug)]
pub struct GroupLabel(pub String);
impl AssistLabel {
pub(crate) fn new(label: String, id: AssistId) -> AssistLabel {
pub(crate) fn new(id: AssistId, label: String) -> 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 }