(pos int, prefixSpace bool, forceNoNewline bool)
| 5588 | } |
| 5589 | |
| 5590 | func (p *Printer) emitTrailingCommentsOfPosition(pos int, prefixSpace bool, forceNoNewline bool) { |
| 5591 | if p.commentsDisabled || p.currentSourceFile == nil { |
| 5592 | return |
| 5593 | } |
| 5594 | if p.containerEnd != -1 && (pos == p.containerEnd || pos == p.declarationListContainerEnd) { |
| 5595 | return |
| 5596 | } |
| 5597 | |
| 5598 | var comments []ast.CommentRange |
| 5599 | for comment := range scanner.GetTrailingCommentRanges(p.emitContext.Factory.AsNodeFactory(), p.currentSourceFile.Text(), pos) { |
| 5600 | comments = append(comments, comment) |
| 5601 | } |
| 5602 | if len(comments) == 0 { |
| 5603 | return |
| 5604 | } |
| 5605 | |
| 5606 | for _, comment := range comments { |
| 5607 | if prefixSpace { |
| 5608 | if !p.shouldWriteComment(comment) { |
| 5609 | continue |
| 5610 | } |
| 5611 | if !p.writer.IsAtStartOfLine() { |
| 5612 | p.writeSpace() |
| 5613 | } |
| 5614 | p.emitComment(comment) |
| 5615 | if comment.HasTrailingNewLine { |
| 5616 | p.writeLine() |
| 5617 | } |
| 5618 | continue |
| 5619 | } |
| 5620 | |
| 5621 | p.emitComment(comment) |
| 5622 | switch { |
| 5623 | case forceNoNewline: |
| 5624 | if comment.Kind == ast.KindSingleLineCommentTrivia { |
| 5625 | p.writeLine() |
| 5626 | } |
| 5627 | case comment.HasTrailingNewLine: |
| 5628 | p.writeLine() |
| 5629 | default: |
| 5630 | p.writeSpace() |
| 5631 | } |
| 5632 | } |
| 5633 | } |
| 5634 | |
| 5635 | func (p *Printer) emitDetachedCommentsAndUpdateCommentsInfo(textRange core.TextRange) { |
| 5636 | if p.currentSourceFile == nil { |
no test coverage detected