@@ -55,6 +55,29 @@ impl GenericParamsOwnerEdit for ast::Fn {
5555 }
5656}
5757
58+ impl ast:: Fn {
59+ pub fn syntax_editor_get_or_create_generic_param_list (
60+ & self ,
61+ editor : & mut SyntaxEditor ,
62+ ) -> ast:: GenericParamList {
63+ match self . generic_param_list ( ) {
64+ Some ( it) => it,
65+ None => {
66+ let position = if let Some ( name) = self . name ( ) {
67+ crate :: syntax_editor:: Position :: after ( name. syntax )
68+ } else if let Some ( fn_token) = self . fn_token ( ) {
69+ crate :: syntax_editor:: Position :: after ( fn_token)
70+ } else if let Some ( param_list) = self . param_list ( ) {
71+ crate :: syntax_editor:: Position :: before ( param_list. syntax )
72+ } else {
73+ crate :: syntax_editor:: Position :: last_child_of ( self . syntax ( ) )
74+ } ;
75+ syntax_editor_create_generic_param_list ( editor, position)
76+ }
77+ }
78+ }
79+ }
80+
5881impl GenericParamsOwnerEdit for ast:: Impl {
5982 fn get_or_create_generic_param_list ( & self ) -> ast:: GenericParamList {
6083 match self . generic_param_list ( ) {
@@ -191,6 +214,15 @@ fn create_generic_param_list(position: Position) -> ast::GenericParamList {
191214 gpl
192215}
193216
217+ fn syntax_editor_create_generic_param_list (
218+ editor : & mut SyntaxEditor ,
219+ position : crate :: syntax_editor:: Position ,
220+ ) -> ast:: GenericParamList {
221+ let gpl = make:: generic_param_list ( empty ( ) ) . clone_for_update ( ) ;
222+ editor. insert ( position, gpl. syntax ( ) ) ;
223+ gpl
224+ }
225+
194226pub trait AttrsOwnerEdit : ast:: HasAttrs {
195227 fn remove_attrs_and_docs ( & self ) {
196228 remove_attrs_and_docs ( self . syntax ( ) ) ;
0 commit comments