String (PsiBinaryExpression expression, CommentTracker commentTracker) { PsiPolyadicExpression conjunction = tryCast(PsiUtil.skipParenthesizedExprDown(expression.getLOperand()), PsiPolyadicExpression.class); if (conjunction == null) return null; final PsiExpression rightDisjunct = PsiUtil.skipParenthesizedExprDown(expression.getROperand()); if (rightDisjunct == null) return null; if (hasOperand(conjunction, rightDisjunct)) return commentTracker.text(rightDisjunct); PsiExpression[] operands = conjunction.getOperands(); if (operands.length < 2) return null; // incomplete boolean isFirst; if (BoolUtils.areExpressionsOpposite(operands[0], rightDisjunct)) { isFirst = true; } else if (BoolUtils.areExpressionsOpposite(operands[operands.length - 1], rightDisjunct)) { isFirst = false; } else { return null; } String conjunctionRemnant; if (operands.length == 2) { conjunctionRemnant = commentTracker.text(operands[isFirst ? 1 : 0], ParenthesesUtils.OR_PRECEDENCE); } else { if (isFirst) { conjunctionRemnant = commentTracker.rangeText(operands[1], operands[operands.length - 1]); } else { conjunctionRemnant = commentTracker.rangeText(operands[0], operands[operands.length - 2]); } if (expression.getLOperand() instanceof PsiParenthesizedExpression) { conjunctionRemnant = "(" + conjunctionRemnant + ")"; } } return isFirst ? commentTracker.text(rightDisjunct, ParenthesesUtils.OR_PRECEDENCE) + "||" + conjunctionRemnant : conjunctionRemnant + "||" + commentTracker.text(rightDisjunct, ParenthesesUtils.OR_PRECEDENCE); }