Cleanup
This commit is contained in:
parent
2d95047f7c
commit
6ac9c4ad6a
@ -57,7 +57,7 @@ pub(crate) struct AssistCtx<'a> {
|
|||||||
should_compute_edit: bool,
|
should_compute_edit: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Clone for AssistCtx<'a> {
|
impl Clone for AssistCtx<'_> {
|
||||||
fn clone(&self) -> Self {
|
fn clone(&self) -> Self {
|
||||||
AssistCtx {
|
AssistCtx {
|
||||||
db: self.db,
|
db: self.db,
|
||||||
@ -80,8 +80,7 @@ impl<'a> AssistCtx<'a> {
|
|||||||
label: impl Into<String>,
|
label: impl Into<String>,
|
||||||
f: impl FnOnce(&mut ActionBuilder),
|
f: impl FnOnce(&mut ActionBuilder),
|
||||||
) -> Option<Assist> {
|
) -> Option<Assist> {
|
||||||
let label = AssistLabel { label: label.into(), id };
|
let label = AssistLabel::new(label.into(), id);
|
||||||
assert!(label.label.chars().nth(0).unwrap().is_uppercase());
|
|
||||||
|
|
||||||
let assist = if self.should_compute_edit {
|
let assist = if self.should_compute_edit {
|
||||||
let action = {
|
let action = {
|
||||||
@ -103,7 +102,7 @@ impl<'a> AssistCtx<'a> {
|
|||||||
label: impl Into<String>,
|
label: impl Into<String>,
|
||||||
f: impl FnOnce() -> Vec<ActionBuilder>,
|
f: impl FnOnce() -> Vec<ActionBuilder>,
|
||||||
) -> Option<Assist> {
|
) -> Option<Assist> {
|
||||||
let label = AssistLabel { label: label.into(), id };
|
let label = AssistLabel::new(label.into(), id);
|
||||||
let assist = if self.should_compute_edit {
|
let assist = if self.should_compute_edit {
|
||||||
let actions = f();
|
let actions = f();
|
||||||
assert!(!actions.is_empty(), "Assist cannot have no");
|
assert!(!actions.is_empty(), "Assist cannot have no");
|
||||||
|
@ -34,6 +34,14 @@ pub struct AssistLabel {
|
|||||||
pub id: AssistId,
|
pub id: AssistId,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl AssistLabel {
|
||||||
|
pub(crate) fn new(label: String, id: AssistId) -> AssistLabel {
|
||||||
|
// FIXME: make fields private, so that this invariant can't be broken
|
||||||
|
assert!(label.chars().nth(0).unwrap().is_uppercase());
|
||||||
|
AssistLabel { label: label.into(), id }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct AssistAction {
|
pub struct AssistAction {
|
||||||
pub label: Option<String>,
|
pub label: Option<String>,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user