(parentNode *ast.Node, lastChild *ast.Node, format ListFormat, childrenTextRange core.TextRange)
| 599 | } |
| 600 | |
| 601 | func (p *Printer) getClosingLineTerminatorCount(parentNode *ast.Node, lastChild *ast.Node, format ListFormat, childrenTextRange core.TextRange) int { |
| 602 | if format&LFPreserveLines != 0 || p.Options.PreserveSourceNewlines { |
| 603 | if format&LFPreferNewLine != 0 { |
| 604 | return 1 |
| 605 | } |
| 606 | if lastChild == nil { |
| 607 | return core.IfElse(parentNode == nil || p.currentSourceFile != nil && RangeIsOnSingleLine(parentNode.Loc, p.currentSourceFile), 0, 1) |
| 608 | } |
| 609 | if p.currentSourceFile != nil && parentNode != nil && !ast.PositionIsSynthesized(parentNode.Pos()) && !ast.NodeIsSynthesized(lastChild) && (lastChild.Parent == nil || lastChild.Parent == parentNode) { |
| 610 | if p.Options.PreserveSourceNewlines { |
| 611 | end := greatestEnd(lastChild.End(), childrenTextRange) |
| 612 | return p.getEffectiveLines( |
| 613 | func(includeComments bool) int { |
| 614 | return getLinesBetweenPositionAndNextNonWhitespaceCharacter( |
| 615 | end, |
| 616 | parentNode.End(), |
| 617 | p.currentSourceFile, |
| 618 | includeComments, |
| 619 | ) |
| 620 | }, |
| 621 | ) |
| 622 | } |
| 623 | return core.IfElse(rangeEndPositionsAreOnSameLine(parentNode.Loc, lastChild.Loc, p.currentSourceFile), 0, 1) |
| 624 | } |
| 625 | if p.shouldEmitOnNewLine(lastChild, format) { |
| 626 | return 1 |
| 627 | } |
| 628 | } |
| 629 | if format&LFMultiLine != 0 && format&LFNoTrailingNewLine == 0 { |
| 630 | return 1 |
| 631 | } |
| 632 | return 0 |
| 633 | } |
| 634 | |
| 635 | func (p *Printer) writeCommentRange(comment ast.CommentRange) { |
| 636 | if p.currentSourceFile == nil { |
no test coverage detected