@@ -2966,16 +2966,16 @@ func (p *Printer) willEmitLeadingNewLine(node *ast.Expression) bool {
2966
2966
2967
2967
// For PartiallyEmittedExpression, recursively check the inner expression
2968
2968
if node .Kind == ast .KindPartiallyEmittedExpression {
2969
- pee := node .AsPartiallyEmittedExpression ()
2970
- if node .Pos () != pee .Expression .Pos () {
2971
- trailingCommentRanges := scanner .GetTrailingCommentRanges (p .emitContext .Factory .AsNodeFactory (), p .currentSourceFile .Text (), pee .Expression .Pos ())
2969
+ partiallyEmitted := node .AsPartiallyEmittedExpression ()
2970
+ if node .Pos () != partiallyEmitted .Expression .Pos () {
2971
+ trailingCommentRanges := scanner .GetTrailingCommentRanges (p .emitContext .Factory .AsNodeFactory (), p .currentSourceFile .Text (), partiallyEmitted .Expression .Pos ())
2972
2972
for comment := range trailingCommentRanges {
2973
2973
if p .commentWillEmitNewLine (comment ) {
2974
2974
return true
2975
2975
}
2976
2976
}
2977
2977
}
2978
- return p .willEmitLeadingNewLine (pee .Expression )
2978
+ return p .willEmitLeadingNewLine (partiallyEmitted .Expression )
2979
2979
}
2980
2980
2981
2981
return false
@@ -3007,87 +3007,87 @@ func (p *Printer) parenthesizeExpressionForNoAsi(node *ast.Expression) *ast.Expr
3007
3007
3008
3008
switch node .Kind {
3009
3009
case ast .KindPartiallyEmittedExpression :
3010
- pee := node .AsPartiallyEmittedExpression ()
3010
+ partiallyEmitted := node .AsPartiallyEmittedExpression ()
3011
3011
if p .willEmitLeadingNewLine (node ) {
3012
3012
// !!! if there is an original parse tree node, restore it with location to preserve comments and source maps.
3013
3013
// Emit with parentheses precedence to force wrapping
3014
3014
return p .createParenthesizedExpressionForNoAsi (node )
3015
3015
}
3016
3016
// Recursively check the inner expression
3017
- innerParenthesized := p .parenthesizeExpressionForNoAsi (pee .Expression )
3018
- if innerParenthesized != pee .Expression {
3017
+ innerParenthesized := p .parenthesizeExpressionForNoAsi (partiallyEmitted .Expression )
3018
+ if innerParenthesized != partiallyEmitted .Expression {
3019
3019
// Need to create a new PartiallyEmittedExpression with the parenthesized inner expression
3020
- return p .updatePartiallyEmittedExpression (pee , innerParenthesized )
3020
+ return p .updatePartiallyEmittedExpression (partiallyEmitted , innerParenthesized )
3021
3021
}
3022
3022
3023
3023
case ast .KindPropertyAccessExpression :
3024
- pae := node .AsPropertyAccessExpression ()
3025
- exprParenthesized := p .parenthesizeExpressionForNoAsi (pae .Expression )
3026
- if exprParenthesized != pae .Expression {
3027
- return p .updatePropertyAccessExpression (pae , exprParenthesized )
3024
+ propertyAccess := node .AsPropertyAccessExpression ()
3025
+ exprParenthesized := p .parenthesizeExpressionForNoAsi (propertyAccess .Expression )
3026
+ if exprParenthesized != propertyAccess .Expression {
3027
+ return p .updatePropertyAccessExpression (propertyAccess , exprParenthesized )
3028
3028
}
3029
3029
3030
3030
case ast .KindElementAccessExpression :
3031
- eae := node .AsElementAccessExpression ()
3032
- exprParenthesized := p .parenthesizeExpressionForNoAsi (eae .Expression )
3033
- if exprParenthesized != eae .Expression {
3034
- return p .updateElementAccessExpression (eae , exprParenthesized )
3031
+ elementAccess := node .AsElementAccessExpression ()
3032
+ exprParenthesized := p .parenthesizeExpressionForNoAsi (elementAccess .Expression )
3033
+ if exprParenthesized != elementAccess .Expression {
3034
+ return p .updateElementAccessExpression (elementAccess , exprParenthesized )
3035
3035
}
3036
3036
3037
3037
case ast .KindCallExpression :
3038
- ce := node .AsCallExpression ()
3039
- exprParenthesized := p .parenthesizeExpressionForNoAsi (ce .Expression )
3040
- if exprParenthesized != ce .Expression {
3041
- return p .updateCallExpression (ce , exprParenthesized )
3038
+ callExpr := node .AsCallExpression ()
3039
+ exprParenthesized := p .parenthesizeExpressionForNoAsi (callExpr .Expression )
3040
+ if exprParenthesized != callExpr .Expression {
3041
+ return p .updateCallExpression (callExpr , exprParenthesized )
3042
3042
}
3043
3043
3044
3044
case ast .KindTaggedTemplateExpression :
3045
- tte := node .AsTaggedTemplateExpression ()
3046
- tagParenthesized := p .parenthesizeExpressionForNoAsi (tte .Tag )
3047
- if tagParenthesized != tte .Tag {
3048
- return p .updateTaggedTemplateExpression (tte , tagParenthesized )
3045
+ taggedTemplate := node .AsTaggedTemplateExpression ()
3046
+ tagParenthesized := p .parenthesizeExpressionForNoAsi (taggedTemplate .Tag )
3047
+ if tagParenthesized != taggedTemplate .Tag {
3048
+ return p .updateTaggedTemplateExpression (taggedTemplate , tagParenthesized )
3049
3049
}
3050
3050
3051
3051
case ast .KindPostfixUnaryExpression :
3052
- pue := node .AsPostfixUnaryExpression ()
3053
- operandParenthesized := p .parenthesizeExpressionForNoAsi (pue .Operand )
3054
- if operandParenthesized != pue .Operand {
3055
- return p .updatePostfixUnaryExpression (pue , operandParenthesized )
3052
+ postfixUnary := node .AsPostfixUnaryExpression ()
3053
+ operandParenthesized := p .parenthesizeExpressionForNoAsi (postfixUnary .Operand )
3054
+ if operandParenthesized != postfixUnary .Operand {
3055
+ return p .updatePostfixUnaryExpression (postfixUnary , operandParenthesized )
3056
3056
}
3057
3057
3058
3058
case ast .KindBinaryExpression :
3059
- be := node .AsBinaryExpression ()
3060
- leftParenthesized := p .parenthesizeExpressionForNoAsi (be .Left )
3061
- if leftParenthesized != be .Left {
3062
- return p .updateBinaryExpression (be , leftParenthesized )
3059
+ binaryExpr := node .AsBinaryExpression ()
3060
+ leftParenthesized := p .parenthesizeExpressionForNoAsi (binaryExpr .Left )
3061
+ if leftParenthesized != binaryExpr .Left {
3062
+ return p .updateBinaryExpression (binaryExpr , leftParenthesized )
3063
3063
}
3064
3064
3065
3065
case ast .KindConditionalExpression :
3066
- ce := node .AsConditionalExpression ()
3067
- conditionParenthesized := p .parenthesizeExpressionForNoAsi (ce .Condition )
3068
- if conditionParenthesized != ce .Condition {
3069
- return p .updateConditionalExpression (ce , conditionParenthesized )
3066
+ conditionalExpr := node .AsConditionalExpression ()
3067
+ conditionParenthesized := p .parenthesizeExpressionForNoAsi (conditionalExpr .Condition )
3068
+ if conditionParenthesized != conditionalExpr .Condition {
3069
+ return p .updateConditionalExpression (conditionalExpr , conditionParenthesized )
3070
3070
}
3071
3071
3072
3072
case ast .KindAsExpression :
3073
- ae := node .AsAsExpression ()
3074
- exprParenthesized := p .parenthesizeExpressionForNoAsi (ae .Expression )
3075
- if exprParenthesized != ae .Expression {
3076
- return p .updateAsExpression (ae , exprParenthesized )
3073
+ asExpr := node .AsAsExpression ()
3074
+ exprParenthesized := p .parenthesizeExpressionForNoAsi (asExpr .Expression )
3075
+ if exprParenthesized != asExpr .Expression {
3076
+ return p .updateAsExpression (asExpr , exprParenthesized )
3077
3077
}
3078
3078
3079
3079
case ast .KindSatisfiesExpression :
3080
- se := node .AsSatisfiesExpression ()
3081
- exprParenthesized := p .parenthesizeExpressionForNoAsi (se .Expression )
3082
- if exprParenthesized != se .Expression {
3083
- return p .updateSatisfiesExpression (se , exprParenthesized )
3080
+ satisfiesExpr := node .AsSatisfiesExpression ()
3081
+ exprParenthesized := p .parenthesizeExpressionForNoAsi (satisfiesExpr .Expression )
3082
+ if exprParenthesized != satisfiesExpr .Expression {
3083
+ return p .updateSatisfiesExpression (satisfiesExpr , exprParenthesized )
3084
3084
}
3085
3085
3086
3086
case ast .KindNonNullExpression :
3087
- nne := node .AsNonNullExpression ()
3088
- exprParenthesized := p .parenthesizeExpressionForNoAsi (nne .Expression )
3089
- if exprParenthesized != nne .Expression {
3090
- return p .updateNonNullExpression (nne , exprParenthesized )
3087
+ nonNullExpr := node .AsNonNullExpression ()
3088
+ exprParenthesized := p .parenthesizeExpressionForNoAsi (nonNullExpr .Expression )
3089
+ if exprParenthesized != nonNullExpr .Expression {
3090
+ return p .updateNonNullExpression (nonNullExpr , exprParenthesized )
3091
3091
}
3092
3092
}
3093
3093
0 commit comments