@@ -269911,6 +269911,7 @@ val hasOptionalAttribute : Parsetree.attributes -> bool
269911
269911
val shouldIndentBinaryExpr : Parsetree.expression -> bool
269912
269912
val shouldInlineRhsBinaryExpr : Parsetree.expression -> bool
269913
269913
val hasPrintableAttributes : Parsetree.attributes -> bool
269914
+ val filterPrintableAttributes : Parsetree.attributes -> Parsetree.attributes
269914
269915
val partitionPrintableAttributes :
269915
269916
Parsetree.attributes -> Parsetree.attributes * Parsetree.attributes
269916
269917
@@ -270500,6 +270501,8 @@ let isPrintableAttribute attr =
270500
270501
270501
270502
let hasPrintableAttributes attrs = List.exists isPrintableAttribute attrs
270502
270503
270504
+ let filterPrintableAttributes attrs = List.filter isPrintableAttribute attrs
270505
+
270503
270506
let partitionPrintableAttributes attrs =
270504
270507
List.partition isPrintableAttribute attrs
270505
270508
@@ -275160,7 +275163,7 @@ val subBinaryExprOperand : string -> string -> bool
275160
275163
val rhsBinaryExprOperand : string -> Parsetree.expression -> bool
275161
275164
val flattenOperandRhs : string -> Parsetree.expression -> bool
275162
275165
275163
- val lazyOrAssertExprRhs : Parsetree.expression -> kind
275166
+ val lazyOrAssertOrAwaitExprRhs : Parsetree.expression -> kind
275164
275167
275165
275168
val fieldExpr : Parsetree.expression -> kind
275166
275169
@@ -275364,7 +275367,7 @@ let flattenOperandRhs parentOperator rhs =
275364
275367
| _ when ParsetreeViewer.isTernaryExpr rhs -> true
275365
275368
| _ -> false
275366
275369
275367
- let lazyOrAssertExprRhs expr =
275370
+ let lazyOrAssertOrAwaitExprRhs expr =
275368
275371
let optBraces, _ = ParsetreeViewer.processBracesAttr expr in
275369
275372
match optBraces with
275370
275373
| Some ({Location.loc = bracesLoc}, _) -> Braced bracesLoc
@@ -278742,7 +278745,7 @@ and printExpression ~customLayout (e : Parsetree.expression) cmtTbl =
278742
278745
| Pexp_assert expr ->
278743
278746
let rhs =
278744
278747
let doc = printExpressionWithComments ~customLayout expr cmtTbl in
278745
- match Parens.lazyOrAssertExprRhs expr with
278748
+ match Parens.lazyOrAssertOrAwaitExprRhs expr with
278746
278749
| Parens.Parenthesized -> addParens doc
278747
278750
| Braced braces -> printBraces doc expr braces
278748
278751
| Nothing -> doc
@@ -278751,7 +278754,7 @@ and printExpression ~customLayout (e : Parsetree.expression) cmtTbl =
278751
278754
| Pexp_lazy expr ->
278752
278755
let rhs =
278753
278756
let doc = printExpressionWithComments ~customLayout expr cmtTbl in
278754
- match Parens.lazyOrAssertExprRhs expr with
278757
+ match Parens.lazyOrAssertOrAwaitExprRhs expr with
278755
278758
| Parens.Parenthesized -> addParens doc
278756
278759
| Braced braces -> printBraces doc expr braces
278757
278760
| Nothing -> doc
@@ -278929,7 +278932,24 @@ and printExpression ~customLayout (e : Parsetree.expression) cmtTbl =
278929
278932
in
278930
278933
let exprWithAwait =
278931
278934
if ParsetreeViewer.hasAwaitAttribute e.pexp_attributes then
278932
- Doc.concat [Doc.text "await "; printedExpression]
278935
+ let rhs =
278936
+ match
278937
+ Parens.lazyOrAssertOrAwaitExprRhs
278938
+ {
278939
+ e with
278940
+ pexp_attributes =
278941
+ List.filter
278942
+ (function
278943
+ | {Location.txt = "res.await" | "ns.braces"}, _ -> false
278944
+ | _ -> true)
278945
+ e.pexp_attributes;
278946
+ }
278947
+ with
278948
+ | Parens.Parenthesized -> addParens printedExpression
278949
+ | Braced braces -> printBraces printedExpression e braces
278950
+ | Nothing -> printedExpression
278951
+ in
278952
+ Doc.concat [Doc.text "await "; rhs]
278933
278953
else printedExpression
278934
278954
in
278935
278955
let shouldPrintItsOwnAttributes =
@@ -279327,11 +279347,7 @@ and printBinaryExpression ~customLayout (expr : Parsetree.expression) cmtTbl =
279327
279347
{
279328
279348
expr with
279329
279349
pexp_attributes =
279330
- List.filter
279331
- (fun attr ->
279332
- match attr with
279333
- | {Location.txt = "ns.braces"}, _ -> false
279334
- | _ -> true)
279350
+ ParsetreeViewer.filterPrintableAttributes
279335
279351
expr.pexp_attributes;
279336
279352
}
279337
279353
with
0 commit comments