@@ -1491,6 +1491,54 @@ impl SyntaxFactory {
14911491 ast
14921492 }
14931493
1494+ pub fn impl_ (
1495+ & self ,
1496+ attrs : impl IntoIterator < Item = ast:: Attr > ,
1497+ generic_params : Option < ast:: GenericParamList > ,
1498+ generic_args : Option < ast:: GenericArgList > ,
1499+ path_type : ast:: Type ,
1500+ where_clause : Option < ast:: WhereClause > ,
1501+ body : Option < ast:: AssocItemList > ,
1502+ ) -> ast:: Impl {
1503+ let ( attrs, attrs_input) = iterator_input ( attrs) ;
1504+ let ast = make:: impl_ (
1505+ attrs,
1506+ generic_params. clone ( ) ,
1507+ generic_args. clone ( ) ,
1508+ path_type. clone ( ) ,
1509+ where_clause. clone ( ) ,
1510+ body. clone ( ) ,
1511+ )
1512+ . clone_for_update ( ) ;
1513+
1514+ if let Some ( mut mapping) = self . mappings ( ) {
1515+ let mut builder = SyntaxMappingBuilder :: new ( ast. syntax ( ) . clone ( ) ) ;
1516+ builder. map_children ( attrs_input, ast. attrs ( ) . map ( |attr| attr. syntax ( ) . clone ( ) ) ) ;
1517+ if let Some ( generic_params) = generic_params {
1518+ builder. map_node (
1519+ generic_params. syntax ( ) . clone ( ) ,
1520+ ast. generic_param_list ( ) . unwrap ( ) . syntax ( ) . clone ( ) ,
1521+ ) ;
1522+ }
1523+ builder. map_node ( path_type. syntax ( ) . clone ( ) , ast. self_ty ( ) . unwrap ( ) . syntax ( ) . clone ( ) ) ;
1524+ if let Some ( where_clause) = where_clause {
1525+ builder. map_node (
1526+ where_clause. syntax ( ) . clone ( ) ,
1527+ ast. where_clause ( ) . unwrap ( ) . syntax ( ) . clone ( ) ,
1528+ ) ;
1529+ }
1530+ if let Some ( body) = body {
1531+ builder. map_node (
1532+ body. syntax ( ) . clone ( ) ,
1533+ ast. assoc_item_list ( ) . unwrap ( ) . syntax ( ) . clone ( ) ,
1534+ ) ;
1535+ }
1536+ builder. finish ( & mut mapping) ;
1537+ }
1538+
1539+ ast
1540+ }
1541+
14941542 pub fn attr_outer ( & self , meta : ast:: Meta ) -> ast:: Attr {
14951543 let ast = make:: attr_outer ( meta. clone ( ) ) . clone_for_update ( ) ;
14961544
@@ -1551,6 +1599,51 @@ impl SyntaxFactory {
15511599 }
15521600 }
15531601
1602+ pub fn self_param ( & self ) -> ast:: SelfParam {
1603+ let ast = make:: self_param ( ) . clone_for_update ( ) ;
1604+
1605+ if let Some ( mut mapping) = self . mappings ( ) {
1606+ SyntaxMappingBuilder :: new ( ast. syntax ( ) . clone ( ) ) . finish ( & mut mapping) ;
1607+ }
1608+
1609+ ast
1610+ }
1611+
1612+ pub fn mut_self_param ( & self ) -> ast:: SelfParam {
1613+ let ast = make:: mut_self_param ( ) . clone_for_update ( ) ;
1614+
1615+ if let Some ( mut mapping) = self . mappings ( ) {
1616+ SyntaxMappingBuilder :: new ( ast. syntax ( ) . clone ( ) ) . finish ( & mut mapping) ;
1617+ }
1618+
1619+ ast
1620+ }
1621+
1622+ pub fn ret_type ( & self , ty : ast:: Type ) -> ast:: RetType {
1623+ let ast = make:: ret_type ( ty. clone ( ) ) . clone_for_update ( ) ;
1624+
1625+ if let Some ( mut mapping) = self . mappings ( ) {
1626+ let mut builder = SyntaxMappingBuilder :: new ( ast. syntax ( ) . clone ( ) ) ;
1627+ builder. map_node ( ty. syntax ( ) . clone ( ) , ast. ty ( ) . unwrap ( ) . syntax ( ) . clone ( ) ) ;
1628+ builder. finish ( & mut mapping) ;
1629+ }
1630+
1631+ ast
1632+ }
1633+
1634+ pub fn ty_ref ( & self , target : ast:: Type , exclusive : bool ) -> ast:: Type {
1635+ let ast = make:: ty_ref ( target. clone ( ) , exclusive) . clone_for_update ( ) ;
1636+
1637+ if let Some ( mut mapping) = self . mappings ( ) {
1638+ let ast:: Type :: RefType ( ref_type) = & ast else { unreachable ! ( ) } ;
1639+ let mut builder = SyntaxMappingBuilder :: new ( ref_type. syntax ( ) . clone ( ) ) ;
1640+ builder. map_node ( target. syntax ( ) . clone ( ) , ref_type. ty ( ) . unwrap ( ) . syntax ( ) . clone ( ) ) ;
1641+ builder. finish ( & mut mapping) ;
1642+ }
1643+
1644+ ast
1645+ }
1646+
15541647 pub fn token ( & self , kind : SyntaxKind ) -> SyntaxToken {
15551648 make:: token ( kind)
15561649 }
0 commit comments