@@ -62,17 +62,6 @@ impl SwiftContext {
6262 }
6363}
6464
65- fn block_with_anchor (
66- ctx : & mut yeast:: build:: BuildCtx < ' _ , SwiftContext > ,
67- statements : Vec < yeast:: Id > ,
68- anchor : Option < yeast:: Id > ,
69- ) -> yeast:: Id {
70- match anchor {
71- Some ( anchor) => tree_at ! ( ctx, anchor, ( block stmt: { statements} ) ) ,
72- None => tree ! ( ctx, ( block stmt: { statements} ) ) ,
73- }
74- }
75-
7665/// Build a freshly-created `chained_declaration` modifier node if
7766/// `ctx.is_chained`, else `None`. Used by inner declaration rules to
7867/// emit the chained tag for non-first children of a flattening outer
@@ -301,6 +290,7 @@ fn translation_rules() -> Vec<Rule<SwiftContext>> {
301290 rule!( ( tupleExpr elements: _* @elements) => ( tuple_expr element: { elements} ) ) ,
302291 // A code block contains its statements directly.
303292 rule!( ( codeBlock statements: _* @stmts) => ( block stmt: { stmts} ) ) ,
293+ rule!( ( accessorBlock accessors: ( codeBlockItem) * @stmts) => ( block stmt: { stmts} ) ) ,
304294 // ---- Properties with accessors ----
305295 // A computed property with an implicit getter (`var a: T { <stmts> }`)
306296 // becomes a single `accessor_declaration` of kind `get`. This form is
@@ -313,14 +303,14 @@ fn translation_rules() -> Vec<Rule<SwiftContext>> {
313303 bindings: ( patternBinding
314304 pattern: ( identifierPattern identifier: @@name)
315305 typeAnnotation: ( typeAnnotation type : @ty)
316- accessorBlock: ( accessorBlock accessors: ( codeBlockItem) + @body ) @@accessor_block ) )
306+ accessorBlock: ( accessorBlock accessors: ( codeBlockItem) +) @body ) )
317307 =>
318308 ( accessor_declaration
319309 modifier: ( modifier #{ spec} )
320310 name_node: ( identifier #{ name} )
321311 type : { ty}
322- accessor_kind: { ctx. literal_at_start_of( "accessor_kind" , "get" , accessor_block ) }
323- body: { block_with_anchor ( & mut ctx , body, Some ( accessor_block ) ) } )
312+ accessor_kind: { ctx. literal_at_start_of( "accessor_kind" , "get" , body ) }
313+ body: { body} )
324314 ) ,
325315 // A property with an explicit accessor block. swift-syntax makes both
326316 // shapes plain `accessorDecl`s, so they are told apart by the presence
@@ -485,11 +475,10 @@ fn translation_rules() -> Vec<Rule<SwiftContext>> {
485475 parameterClause: ( enumCaseParameterClause parameters: _* @params) @@clause)
486476 =>
487477 class_like_declaration {
488- let body = tree!( ( block) ) ;
489478 let constructor = tree_spanning!(
490479 ctx,
491480 [ name, clause] ,
492- ( constructor_declaration parameter: { params} body: { body } )
481+ ( constructor_declaration parameter: { params} body: ( block ) )
493482 ) ;
494483 tree!( ( class_like_declaration
495484 modifier: { ctx. outer_modifiers. clone( ) }
@@ -803,14 +792,14 @@ fn translation_rules() -> Vec<Rule<SwiftContext>> {
803792 capture: ( closureCaptureClause items: _* @captures) ?
804793 parameterClause: _* @params
805794 returnClause: ( returnClause type : @ret) ?) ?
806- statements: _* @body) @@closure
795+ statements: _* @body)
807796 =>
808797 ( function_expr
809798 modifier: { attrs}
810799 capture_declaration: { captures}
811800 parameter: { params}
812801 return_type: { ret}
813- body: { block_with_anchor ( & mut ctx , body, Some ( closure ) ) } )
802+ body: ( block stmt : { body} ) )
814803 ) ,
815804 // A closure capture (`[weak self]`, `[x]`, `[y = expr]`). The optional
816805 // ownership specifier (`weak`/`unowned`) becomes a modifier; the
0 commit comments