File tree Expand file tree Collapse file tree 3 files changed +13
-5
lines changed
packages/prettier-plugin-java
test/unit-test/binary_expressions Expand file tree Collapse file tree 3 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -167,8 +167,12 @@ export default {
167167 ( operators . length > 0 && ! children . AssignmentOperator ) ||
168168 ( children . expression !== undefined &&
169169 isBinaryExpression ( children . expression [ 0 ] ) ) ;
170+ const isInList =
171+ ( path . getNode ( 4 ) as JavaNonTerminal | null ) ?. name === "elementValue" ||
172+ ( path . getNode ( 6 ) as JavaNonTerminal | null ) ?. name === "argumentList" ;
170173 return binary ( operands , operators , {
171174 hasNonAssignmentOperators,
175+ isInList,
172176 isRoot : true ,
173177 operatorPosition : options . experimentalOperatorPosition
174178 } ) ;
@@ -627,10 +631,12 @@ function binary(
627631 operators : { image : string ; doc : Doc } [ ] ,
628632 {
629633 hasNonAssignmentOperators = false ,
634+ isInList = false ,
630635 isRoot = false ,
631636 operatorPosition
632637 } : {
633638 hasNonAssignmentOperators ?: boolean ;
639+ isInList ?: boolean ;
634640 isRoot ?: boolean ;
635641 operatorPosition : "end" | "start" ;
636642 }
@@ -686,7 +692,9 @@ function binary(
686692 level . push ( operands . shift ( ) ! ) ;
687693 if (
688694 ! levelOperator ||
689- ( ! isAssignmentOperator ( levelOperator ) && levelOperator !== "instanceof" )
695+ ( ! isInList &&
696+ ! isAssignmentOperator ( levelOperator ) &&
697+ levelOperator !== "instanceof" )
690698 ) {
691699 return group ( level ) ;
692700 }
Original file line number Diff line number Diff line change @@ -7,12 +7,12 @@ public void binaryOperation() {
77
88 @ Annotation (
99 "This operation with two very long string should break" +
10- "in a very nice way"
10+ "in a very nice way"
1111 )
1212 public String binaryOperationThatShouldBreak () {
1313 System .out .println (
1414 "This operation with two very long string should break" +
15- "in a very nice way"
15+ "in a very nice way"
1616 );
1717 return (
1818 "This operation with two very long string should break" +
Original file line number Diff line number Diff line change @@ -7,12 +7,12 @@ public void binaryOperation() {
77
88 @ Annotation (
99 "This operation with two very long string should break"
10- + "in a very nice way"
10+ + "in a very nice way"
1111 )
1212 public String binaryOperationThatShouldBreak () {
1313 System .out .println (
1414 "This operation with two very long string should break"
15- + "in a very nice way"
15+ + "in a very nice way"
1616 );
1717 return (
1818 "This operation with two very long string should break"
You can’t perform that action at this time.
0 commit comments