(node *ast.Expression)
| 3054 | } |
| 3055 | |
| 3056 | func (p *Printer) willEmitLeadingNewLine(node *ast.Expression) bool { |
| 3057 | if p.currentSourceFile == nil { |
| 3058 | return false |
| 3059 | } |
| 3060 | hasLeadingCommentRanges := false |
| 3061 | hasNewLineComment := false |
| 3062 | for comment := range scanner.GetLeadingCommentRanges(p.emitContext.Factory.AsNodeFactory(), p.currentSourceFile.Text(), node.Pos()) { |
| 3063 | hasLeadingCommentRanges = true |
| 3064 | if p.commentWillEmitNewLine(comment) { |
| 3065 | hasNewLineComment = true |
| 3066 | } |
| 3067 | } |
| 3068 | if hasLeadingCommentRanges { |
| 3069 | parseNode := p.emitContext.ParseNode(node) |
| 3070 | if parseNode != nil && ast.IsParenthesizedExpression(parseNode.Parent) { |
| 3071 | return true |
| 3072 | } |
| 3073 | } |
| 3074 | if hasNewLineComment { |
| 3075 | return true |
| 3076 | } |
| 3077 | if slices.ContainsFunc(p.emitContext.GetSyntheticLeadingComments(node), p.syntheticCommentWillEmitNewLine) { |
| 3078 | return true |
| 3079 | } |
| 3080 | if ast.IsPartiallyEmittedExpression(node) { |
| 3081 | pee := node.AsPartiallyEmittedExpression() |
| 3082 | if node.Pos() != pee.Expression.Pos() { |
| 3083 | for comment := range scanner.GetTrailingCommentRanges(p.emitContext.Factory.AsNodeFactory(), p.currentSourceFile.Text(), pee.Expression.Pos()) { |
| 3084 | if p.commentWillEmitNewLine(comment) { |
| 3085 | return true |
| 3086 | } |
| 3087 | } |
| 3088 | } |
| 3089 | return p.willEmitLeadingNewLine(pee.Expression) |
| 3090 | } |
| 3091 | return false |
| 3092 | } |
| 3093 | |
| 3094 | // parenthesizeExpressionForNoAsi wraps an expression in parens if we would emit a leading comment |
| 3095 | // that would introduce a line separator between the node and its parent. |
no test coverage detected