PsiExpression (@NotNull PsiExpression elseRhs, boolean operationIsOpposite) { if (!operationIsOpposite) return elseRhs; final PsiElementFactory factory = JavaPsiFacade.getElementFactory(elseRhs.getProject()); final String elseRhsText; if (elseRhs instanceof PsiPrefixExpression && ((PsiPrefixExpression)elseRhs).getOperationTokenType().equals(JavaTokenType.MINUS)) { final PsiExpression operand = ((PsiPrefixExpression)elseRhs).getOperand(); if (operand != null) { return operand; } } elseRhsText = "-" + ParenthesesUtils.getText(elseRhs, ParenthesesUtils.ADDITIVE_PRECEDENCE); return factory.createExpressionFromText(elseRhsText, elseRhs); }