File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ use crate::{
1414 SyntaxNode , SyntaxToken ,
1515} ;
1616
17- use super :: HasName ;
17+ use super :: { HasArgList , HasName } ;
1818
1919pub trait GenericParamsOwnerEdit : ast:: HasGenericParams {
2020 fn get_or_create_generic_param_list ( & self ) -> ast:: GenericParamList ;
@@ -362,6 +362,24 @@ impl ast::PathSegment {
362362 }
363363}
364364
365+ impl ast:: MethodCallExpr {
366+ pub fn get_or_create_generic_arg_list ( & self ) -> ast:: GenericArgList {
367+ if self . generic_arg_list ( ) . is_none ( ) {
368+ let generic_arg_list = make:: turbofish_generic_arg_list ( empty ( ) ) . clone_for_update ( ) ;
369+
370+ if let Some ( arg_list) = self . arg_list ( ) {
371+ ted:: insert_raw (
372+ ted:: Position :: before ( arg_list. syntax ( ) ) ,
373+ generic_arg_list. syntax ( ) ,
374+ ) ;
375+ } else {
376+ ted:: append_child ( self . syntax ( ) , generic_arg_list. syntax ( ) ) ;
377+ }
378+ }
379+ self . generic_arg_list ( ) . unwrap ( )
380+ }
381+ }
382+
365383impl Removable for ast:: UseTree {
366384 fn remove ( & self ) {
367385 for dir in [ Direction :: Next , Direction :: Prev ] {
Original file line number Diff line number Diff line change @@ -941,6 +941,13 @@ pub fn lifetime_arg(lifetime: ast::Lifetime) -> ast::LifetimeArg {
941941 ast_from_text ( & format ! ( "const S: T<{lifetime}> = ();" ) )
942942}
943943
944+ pub fn turbofish_generic_arg_list (
945+ args : impl IntoIterator < Item = ast:: GenericArg > ,
946+ ) -> ast:: GenericArgList {
947+ let args = args. into_iter ( ) . join ( ", " ) ;
948+ ast_from_text ( & format ! ( "const S: T::<{args}> = ();" ) )
949+ }
950+
944951pub ( crate ) fn generic_arg_list (
945952 args : impl IntoIterator < Item = ast:: GenericArg > ,
946953) -> ast:: GenericArgList {
You can’t perform that action at this time.
0 commit comments