@@ -7,7 +7,6 @@ use parser::{SyntaxKind, T};
7
7
use crate :: {
8
8
algo:: { self , neighbor} ,
9
9
ast:: { self , edit:: IndentLevel , make, HasGenericArgs , HasGenericParams } ,
10
- syntax_editor:: SyntaxEditor ,
11
10
ted:: { self , Position } ,
12
11
AstNode , AstToken , Direction , SyntaxElement ,
13
12
SyntaxKind :: { ATTR , COMMENT , WHITESPACE } ,
@@ -55,78 +54,6 @@ impl GenericParamsOwnerEdit for ast::Fn {
55
54
}
56
55
}
57
56
58
- impl ast:: Fn {
59
- /// Adds a new generic param to the function using `SyntaxEditor`
60
- pub fn syntax_editor_add_generic_param (
61
- & self ,
62
- editor : & mut SyntaxEditor ,
63
- new_param : GenericParam ,
64
- ) {
65
- match self . generic_param_list ( ) {
66
- Some ( generic_param_list) => match generic_param_list. generic_params ( ) . last ( ) {
67
- Some ( last_param) => {
68
- // There exists a generic param list and it's not empty
69
- let position = generic_param_list. r_angle_token ( ) . map_or_else (
70
- || crate :: syntax_editor:: Position :: last_child_of ( self . syntax ( ) ) ,
71
- crate :: syntax_editor:: Position :: before,
72
- ) ;
73
-
74
- if last_param
75
- . syntax ( )
76
- . next_sibling_or_token ( )
77
- . map_or ( false , |it| it. kind ( ) == SyntaxKind :: COMMA )
78
- {
79
- editor. insert (
80
- crate :: syntax_editor:: Position :: after ( last_param. syntax ( ) ) ,
81
- new_param. syntax ( ) . clone ( ) ,
82
- ) ;
83
- editor. insert (
84
- crate :: syntax_editor:: Position :: after ( last_param. syntax ( ) ) ,
85
- make:: token ( SyntaxKind :: WHITESPACE ) ,
86
- ) ;
87
- editor. insert (
88
- crate :: syntax_editor:: Position :: after ( last_param. syntax ( ) ) ,
89
- make:: token ( SyntaxKind :: COMMA ) ,
90
- ) ;
91
- } else {
92
- let elements = vec ! [
93
- make:: token( SyntaxKind :: COMMA ) . into( ) ,
94
- make:: token( SyntaxKind :: WHITESPACE ) . into( ) ,
95
- new_param. syntax( ) . clone( ) . into( ) ,
96
- ] ;
97
- editor. insert_all ( position, elements) ;
98
- }
99
- }
100
- None => {
101
- // There exists a generic param list but it's empty
102
- let position = crate :: syntax_editor:: Position :: after (
103
- generic_param_list. l_angle_token ( ) . unwrap ( ) ,
104
- ) ;
105
- editor. insert ( position, new_param. syntax ( ) ) ;
106
- }
107
- } ,
108
- None => {
109
- // There was no generic param list
110
- let position = if let Some ( name) = self . name ( ) {
111
- crate :: syntax_editor:: Position :: after ( name. syntax )
112
- } else if let Some ( fn_token) = self . fn_token ( ) {
113
- crate :: syntax_editor:: Position :: after ( fn_token)
114
- } else if let Some ( param_list) = self . param_list ( ) {
115
- crate :: syntax_editor:: Position :: before ( param_list. syntax )
116
- } else {
117
- crate :: syntax_editor:: Position :: last_child_of ( self . syntax ( ) )
118
- } ;
119
- let elements = vec ! [
120
- make:: token( SyntaxKind :: L_ANGLE ) . into( ) ,
121
- new_param. syntax( ) . clone( ) . into( ) ,
122
- make:: token( SyntaxKind :: R_ANGLE ) . into( ) ,
123
- ] ;
124
- editor. insert_all ( position, elements) ;
125
- }
126
- }
127
- }
128
- }
129
-
130
57
impl GenericParamsOwnerEdit for ast:: Impl {
131
58
fn get_or_create_generic_param_list ( & self ) -> ast:: GenericParamList {
132
59
match self . generic_param_list ( ) {
0 commit comments