Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/syntax/src/ast/edit_in_place.rs')
| -rw-r--r-- | crates/syntax/src/ast/edit_in_place.rs | 73 |
1 files changed, 0 insertions, 73 deletions
diff --git a/crates/syntax/src/ast/edit_in_place.rs b/crates/syntax/src/ast/edit_in_place.rs index 68447a6a27..f1286e7aa2 100644 --- a/crates/syntax/src/ast/edit_in_place.rs +++ b/crates/syntax/src/ast/edit_in_place.rs @@ -7,7 +7,6 @@ use parser::{SyntaxKind, T}; use crate::{ algo::{self, neighbor}, ast::{self, edit::IndentLevel, make, HasGenericArgs, HasGenericParams}, - syntax_editor::SyntaxEditor, ted::{self, Position}, AstNode, AstToken, Direction, SyntaxElement, SyntaxKind::{ATTR, COMMENT, WHITESPACE}, @@ -55,78 +54,6 @@ impl GenericParamsOwnerEdit for ast::Fn { } } -impl ast::Fn { - /// Adds a new generic param to the function using `SyntaxEditor` - pub fn syntax_editor_add_generic_param( - &self, - editor: &mut SyntaxEditor, - new_param: GenericParam, - ) { - match self.generic_param_list() { - Some(generic_param_list) => match generic_param_list.generic_params().last() { - Some(last_param) => { - // There exists a generic param list and it's not empty - let position = generic_param_list.r_angle_token().map_or_else( - || crate::syntax_editor::Position::last_child_of(self.syntax()), - crate::syntax_editor::Position::before, - ); - - if last_param - .syntax() - .next_sibling_or_token() - .map_or(false, |it| it.kind() == SyntaxKind::COMMA) - { - editor.insert( - crate::syntax_editor::Position::after(last_param.syntax()), - new_param.syntax().clone(), - ); - editor.insert( - crate::syntax_editor::Position::after(last_param.syntax()), - make::token(SyntaxKind::WHITESPACE), - ); - editor.insert( - crate::syntax_editor::Position::after(last_param.syntax()), - make::token(SyntaxKind::COMMA), - ); - } else { - let elements = vec![ - make::token(SyntaxKind::COMMA).into(), - make::token(SyntaxKind::WHITESPACE).into(), - new_param.syntax().clone().into(), - ]; - editor.insert_all(position, elements); - } - } - None => { - // There exists a generic param list but it's empty - let position = crate::syntax_editor::Position::after( - generic_param_list.l_angle_token().unwrap(), - ); - editor.insert(position, new_param.syntax()); - } - }, - None => { - // There was no generic param list - 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()) - }; - let elements = vec![ - make::token(SyntaxKind::L_ANGLE).into(), - new_param.syntax().clone().into(), - make::token(SyntaxKind::R_ANGLE).into(), - ]; - editor.insert_all(position, elements); - } - } - } -} - impl GenericParamsOwnerEdit for ast::Impl { fn get_or_create_generic_param_list(&self) -> ast::GenericParamList { match self.generic_param_list() { |