boolean (PsiExpression expr) { PsiBinaryExpression binOp = tryCast(PsiUtil.skipParenthesizedExprDown(expr), PsiBinaryExpression.class); if (binOp == null) return false; if (!ComparisonUtils.isComparisonOperation(binOp.getOperationTokenType())) return false; PsiExpression compared = null; if (PsiUtil.isConstantExpression(binOp.getLOperand())) { compared = PsiUtil.skipParenthesizedExprDown(binOp.getROperand()); } else if (PsiUtil.isConstantExpression(binOp.getROperand())) { compared = PsiUtil.skipParenthesizedExprDown(binOp.getLOperand()); } if (compared == null) return false; if (compared instanceof PsiUnaryExpression) { PsiReferenceExpression operand = tryCast(PsiUtil.skipParenthesizedExprDown(((PsiUnaryExpression)compared).getOperand()), PsiReferenceExpression.class); if (operand != null && PsiUtil.isAccessedForWriting(operand) && operand.getQualifierExpression() == null) { PsiElement target = operand.resolve(); if (target instanceof PsiLocalVariable || target instanceof PsiParameter) return true; } } return false; }