mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-16 17:58:16 +00:00
Merge #7662
7662: Group generate getter/setter assist r=Veykril a=Veykril bors r+ Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
This commit is contained in:
commit
3fdc556632
3 changed files with 12 additions and 12 deletions
|
@ -1,10 +1,9 @@
|
|||
use stdx::{format_to, to_lower_snake_case};
|
||||
use syntax::ast::VisibilityOwner;
|
||||
use syntax::ast::{self, AstNode, NameOwner};
|
||||
use syntax::ast::{self, AstNode, NameOwner, VisibilityOwner};
|
||||
|
||||
use crate::{
|
||||
utils::{find_impl_block_end, find_struct_impl, generate_impl_text},
|
||||
AssistContext, AssistId, AssistKind, Assists,
|
||||
AssistContext, AssistId, AssistKind, Assists, GroupLabel,
|
||||
};
|
||||
|
||||
// Assist: generate_getter
|
||||
|
@ -42,7 +41,8 @@ pub(crate) fn generate_getter(acc: &mut Assists, ctx: &AssistContext) -> Option<
|
|||
let impl_def = find_struct_impl(&ctx, &ast::Adt::Struct(strukt.clone()), fn_name.as_str())?;
|
||||
|
||||
let target = field.syntax().text_range();
|
||||
acc.add(
|
||||
acc.add_group(
|
||||
&GroupLabel("Generate getter/setter".to_owned()),
|
||||
AssistId("generate_getter", AssistKind::Generate),
|
||||
"Generate a getter method",
|
||||
target,
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
use stdx::{format_to, to_lower_snake_case};
|
||||
use syntax::ast::VisibilityOwner;
|
||||
use syntax::ast::{self, AstNode, NameOwner};
|
||||
use syntax::ast::{self, AstNode, NameOwner, VisibilityOwner};
|
||||
|
||||
use crate::{
|
||||
utils::{find_impl_block_end, find_struct_impl, generate_impl_text},
|
||||
AssistContext, AssistId, AssistKind, Assists,
|
||||
AssistContext, AssistId, AssistKind, Assists, GroupLabel,
|
||||
};
|
||||
|
||||
// Assist: generate_getter_mut
|
||||
|
@ -46,7 +45,8 @@ pub(crate) fn generate_getter_mut(acc: &mut Assists, ctx: &AssistContext) -> Opt
|
|||
)?;
|
||||
|
||||
let target = field.syntax().text_range();
|
||||
acc.add(
|
||||
acc.add_group(
|
||||
&GroupLabel("Generate getter/setter".to_owned()),
|
||||
AssistId("generate_getter_mut", AssistKind::Generate),
|
||||
"Generate a mut getter method",
|
||||
target,
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
use stdx::{format_to, to_lower_snake_case};
|
||||
use syntax::ast::VisibilityOwner;
|
||||
use syntax::ast::{self, AstNode, NameOwner};
|
||||
use syntax::ast::{self, AstNode, NameOwner, VisibilityOwner};
|
||||
|
||||
use crate::{
|
||||
utils::{find_impl_block_end, find_struct_impl, generate_impl_text},
|
||||
AssistContext, AssistId, AssistKind, Assists,
|
||||
AssistContext, AssistId, AssistKind, Assists, GroupLabel,
|
||||
};
|
||||
|
||||
// Assist: generate_setter
|
||||
|
@ -46,7 +45,8 @@ pub(crate) fn generate_setter(acc: &mut Assists, ctx: &AssistContext) -> Option<
|
|||
)?;
|
||||
|
||||
let target = field.syntax().text_range();
|
||||
acc.add(
|
||||
acc.add_group(
|
||||
&GroupLabel("Generate getter/setter".to_owned()),
|
||||
AssistId("generate_setter", AssistKind::Generate),
|
||||
"Generate a setter method",
|
||||
target,
|
||||
|
|
Loading…
Reference in a new issue