(body *ast.Block)
| 1583 | } |
| 1584 | |
| 1585 | func (p *Printer) emitFunctionBody(body *ast.Block) { |
| 1586 | p.emitContext.AddEmitFlags(body.AsNode(), EFNoSourceMap) |
| 1587 | |
| 1588 | // Use only notification hooks for the body block, not the full comment pipeline. |
| 1589 | // Without this, trailing comments from the original method declaration |
| 1590 | // (e.g., "// Error") leak into synthesized comma expressions when methods |
| 1591 | // are hoisted into pending expressions. |
| 1592 | if p.OnBeforeEmitNode != nil { |
| 1593 | p.OnBeforeEmitNode(body.AsNode()) |
| 1594 | } |
| 1595 | |
| 1596 | p.generateNames(body.AsNode()) |
| 1597 | |
| 1598 | // !!! Emit with comment after Strada migration |
| 1599 | ////p.emitTokenWithComment(ast.KindOpenBraceToken, body.Pos(), WriteKindPunctuation, body.AsNode()) |
| 1600 | p.writePunctuation("{") |
| 1601 | |
| 1602 | p.increaseIndent() |
| 1603 | detachedState := p.emitDetachedCommentsBeforeStatementList(body.AsNode(), body.Statements.Loc) |
| 1604 | statementOffset := p.emitPrologueDirectives(body.Statements) |
| 1605 | pos := p.writer.GetTextPos() |
| 1606 | p.emitHelpers(body.AsNode()) |
| 1607 | |
| 1608 | if p.shouldEmitBlockFunctionBodyOnSingleLine(body) && statementOffset == 0 && pos == p.writer.GetTextPos() { |
| 1609 | p.decreaseIndent() |
| 1610 | p.emitListRange((*Printer).emitStatement, body.AsNode(), body.Statements, LFSingleLineFunctionBodyStatements, statementOffset, -1) |
| 1611 | p.increaseIndent() |
| 1612 | } else { |
| 1613 | p.emitListRange((*Printer).emitStatement, body.AsNode(), body.Statements, LFMultiLineFunctionBodyStatements, statementOffset, -1) |
| 1614 | } |
| 1615 | |
| 1616 | p.emitDetachedCommentsAfterStatementList(body.AsNode(), body.Statements.Loc, detachedState) |
| 1617 | p.decreaseIndent() |
| 1618 | |
| 1619 | // !!! Emit comment after Strada migration |
| 1620 | ////p.emitTokenEx(ast.KindCloseBraceToken, body.Statements.End(), WriteKindPunctuation, body.AsNode(), tefNone) |
| 1621 | p.emitTokenEx(ast.KindCloseBraceToken, body.Statements.End(), WriteKindPunctuation, body.AsNode(), tefNoComments) |
| 1622 | |
| 1623 | if p.OnAfterEmitNode != nil { |
| 1624 | p.OnAfterEmitNode(body.AsNode()) |
| 1625 | } |
| 1626 | } |
| 1627 | |
| 1628 | func (p *Printer) emitFunctionBodyNode(node *ast.BlockNode) { |
| 1629 | if node == nil { |
no test coverage detected