This repository was archived by the owner on Jun 15, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +17
-21
lines changed Expand file tree Collapse file tree 4 files changed +17
-21
lines changed Original file line number Diff line number Diff line change @@ -126,12 +126,8 @@ type kind = Parenthesized | Braced of Location.t | Nothing
126
126
Pexp_lazy _
127
127
| Pexp_assert _
128
128
} when isLhs -> Parenthesized
129
- | {Parsetree. pexp_attributes = (_ ::_ ) as attrs } ->
130
- begin match ParsetreeViewer. filterPrinteableAttributes attrs with
131
- | [] -> Nothing
132
- | _ -> Parenthesized
133
- end
134
- | _ -> Nothing
129
+ | {Parsetree. pexp_attributes = attrs } ->
130
+ if ParsetreeViewer. hasPrintableAttributes attrs then Parenthesized else Nothing
135
131
end
136
132
137
133
let subBinaryExprOperand parentOperator childOperator =
Original file line number Diff line number Diff line change @@ -451,17 +451,16 @@ let shouldInlineRhsBinaryExpr rhs = match rhs.pexp_desc with
451
451
| Pexp_record _ -> true
452
452
| _ -> false
453
453
454
- let filterPrinteableAttributes attrs =
455
- List. filter ( fun attr -> match attr with
454
+ let isPrintableAttribute attr =
455
+ match attr with
456
456
| ({Location. txt ="bs" | "res.template" | "ns.ternary" | "ns.braces" | "ns.iflet" | "JSX" } , _ ) -> false
457
457
| _ -> true
458
- ) attrs
459
458
460
- let partitionPrinteableAttributes attrs =
461
- List. partition ( fun attr -> match attr with
462
- | ( { Location. txt = "bs" | "res.template" | "ns.ternary" | "ns.iflet" | "JSX" } , _ ) -> false
463
- | _ -> true
464
- ) attrs
459
+ let hasPrintableAttributes attrs = List. exists isPrintableAttribute attrs
460
+
461
+ let filterPrintableAttributes attrs = List. filter isPrintableAttribute attrs
462
+
463
+ let partitionPrintableAttributes attrs = List. partition isPrintableAttribute attrs
465
464
466
465
let requiresSpecialCallbackPrintingLastArg args =
467
466
let rec loop args = match args with
Original file line number Diff line number Diff line change @@ -81,8 +81,9 @@ val hasJsxAttribute: Parsetree.attributes -> bool
81
81
82
82
val shouldIndentBinaryExpr : Parsetree .expression -> bool
83
83
val shouldInlineRhsBinaryExpr : Parsetree .expression -> bool
84
- val filterPrinteableAttributes : Parsetree .attributes -> Parsetree .attributes
85
- val partitionPrinteableAttributes : Parsetree .attributes -> (Parsetree .attributes * Parsetree .attributes )
84
+ val hasPrintableAttributes : Parsetree .attributes -> bool
85
+ val filterPrintableAttributes : Parsetree .attributes -> Parsetree .attributes
86
+ val partitionPrintableAttributes : Parsetree .attributes -> (Parsetree .attributes * Parsetree .attributes )
86
87
87
88
val requiresSpecialCallbackPrintingLastArg : (Asttypes .arg_label * Parsetree .expression ) list -> bool
88
89
val requiresSpecialCallbackPrintingFirstArg : (Asttypes .arg_label * Parsetree .expression ) list -> bool
Original file line number Diff line number Diff line change @@ -3479,7 +3479,7 @@ and printBinaryExpression (expr : Parsetree.expression) cmtTbl =
3479
3479
let leftPrinted = flatten ~is Lhs:true left operator in
3480
3480
let rightPrinted =
3481
3481
let (_, rightAttrs) =
3482
- ParsetreeViewer. partitionPrinteableAttributes right.pexp_attributes
3482
+ ParsetreeViewer. partitionPrintableAttributes right.pexp_attributes
3483
3483
in
3484
3484
let doc =
3485
3485
printExpressionWithComments
@@ -3491,11 +3491,11 @@ and printBinaryExpression (expr : Parsetree.expression) cmtTbl =
3491
3491
else
3492
3492
doc
3493
3493
in
3494
- let printeableAttrs =
3495
- ParsetreeViewer. filterPrinteableAttributes right.pexp_attributes
3494
+ let printableAttrs =
3495
+ ParsetreeViewer. filterPrintableAttributes right.pexp_attributes
3496
3496
in
3497
- let doc = Doc. concat [printAttributes printeableAttrs cmtTbl; doc] in
3498
- match printeableAttrs with
3497
+ let doc = Doc. concat [printAttributes printableAttrs cmtTbl; doc] in
3498
+ match printableAttrs with
3499
3499
| [] -> doc
3500
3500
| _ -> addParens doc
3501
3501
in
You can’t perform that action at this time.
0 commit comments