mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 05:15:04 +00:00
fix: implement syntax_editor_create_generic_param_list
Signed-off-by: Tarek <tareknaser360@gmail.com>
This commit is contained in:
parent
642d4f3385
commit
0990d5956d
2 changed files with 35 additions and 5 deletions
|
@ -55,6 +55,29 @@ impl GenericParamsOwnerEdit for ast::Fn {
|
|||
}
|
||||
}
|
||||
|
||||
impl ast::Fn {
|
||||
pub fn syntax_editor_get_or_create_generic_param_list(
|
||||
&self,
|
||||
editor: &mut SyntaxEditor,
|
||||
) -> ast::GenericParamList {
|
||||
match self.generic_param_list() {
|
||||
Some(it) => it,
|
||||
None => {
|
||||
let position = if let Some(name) = self.name() {
|
||||
crate::syntax_editor::Position::after(name.syntax)
|
||||
} else if let Some(fn_token) = self.fn_token() {
|
||||
crate::syntax_editor::Position::after(fn_token)
|
||||
} else if let Some(param_list) = self.param_list() {
|
||||
crate::syntax_editor::Position::before(param_list.syntax)
|
||||
} else {
|
||||
crate::syntax_editor::Position::last_child_of(self.syntax())
|
||||
};
|
||||
syntax_editor_create_generic_param_list(editor, position)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl GenericParamsOwnerEdit for ast::Impl {
|
||||
fn get_or_create_generic_param_list(&self) -> ast::GenericParamList {
|
||||
match self.generic_param_list() {
|
||||
|
@ -191,6 +214,15 @@ fn create_generic_param_list(position: Position) -> ast::GenericParamList {
|
|||
gpl
|
||||
}
|
||||
|
||||
fn syntax_editor_create_generic_param_list(
|
||||
editor: &mut SyntaxEditor,
|
||||
position: crate::syntax_editor::Position,
|
||||
) -> ast::GenericParamList {
|
||||
let gpl = make::generic_param_list(empty()).clone_for_update();
|
||||
editor.insert(position, gpl.syntax());
|
||||
gpl
|
||||
}
|
||||
|
||||
pub trait AttrsOwnerEdit: ast::HasAttrs {
|
||||
fn remove_attrs_and_docs(&self) {
|
||||
remove_attrs_and_docs(self.syntax());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue