@Override public void visitBinaryExpression(@NotNull PsiBinaryExpression expression) { super.visitBinaryExpression(expression); final PsiExpression rhs = expression.getROperand(); if (!(rhs != null)) { return; } if (!ComparisonUtils.isComparison(expression)) { return; } if (ComparisonUtils.isEqualityComparison(expression)) { return; } final PsiExpression lhs = expression.getLOperand(); if (!isCharacter(lhs)) { return; } if (!isCharacter(rhs)) { return; } if (NonNlsUtils.isNonNlsAnnotated(lhs) || NonNlsUtils.isNonNlsAnnotated(rhs)) { return; } registerError(expression); }
@Override public void visitBinaryExpression(@NotNull PsiBinaryExpression expression) { super.visitBinaryExpression(expression); if (!ComparisonUtils.isComparison(expression)) { return; } final PsiExpression lhs = expression.getLOperand(); final PsiExpression rhs = expression.getROperand(); if (rhs == null || !isConstantExpression(lhs) || isConstantExpression(rhs)) { return; } registerError(expression); }
@Override public void visitBinaryExpression(PsiBinaryExpression expression) { super.visitBinaryExpression(expression); final PsiExpression rhs = expression.getROperand(); if (rhs == null) { return; } if (!ComparisonUtils.isComparison(expression)) { return; } final PsiExpression lhs = expression.getLOperand(); if (lhs instanceof PsiMethodCallExpression) { final PsiJavaToken sign = expression.getOperationSign(); if (canBeReplacedByContains(lhs, sign, rhs, false)) { registerError(expression, expression); } } else if (rhs instanceof PsiMethodCallExpression) { final PsiJavaToken sign = expression.getOperationSign(); if (canBeReplacedByContains(rhs, sign, lhs, true)) { registerError(expression, expression); } } }
@Override public void visitBinaryExpression(PsiBinaryExpression expression) { super.visitBinaryExpression(expression); final IElementType operationTokenType = expression.getOperationTokenType(); final PsiExpression lhs = ParenthesesUtils.stripParentheses(expression.getLOperand()); final PsiExpression rhs = ParenthesesUtils.stripParentheses(expression.getROperand()); final PsiBinaryExpression binaryExpression; final PsiExpression possibleInstanceofExpression; if (operationTokenType.equals(JavaTokenType.ANDAND)) { if (lhs instanceof PsiBinaryExpression) { binaryExpression = (PsiBinaryExpression) lhs; possibleInstanceofExpression = rhs; } else if (rhs instanceof PsiBinaryExpression) { binaryExpression = (PsiBinaryExpression) rhs; possibleInstanceofExpression = lhs; } else { return; } final IElementType tokenType = binaryExpression.getOperationTokenType(); if (!tokenType.equals(JavaTokenType.NE)) { return; } } else if (operationTokenType.equals(JavaTokenType.OROR)) { if (lhs instanceof PsiBinaryExpression && rhs instanceof PsiPrefixExpression) { final PsiPrefixExpression prefixExpression = (PsiPrefixExpression) rhs; final IElementType prefixTokenType = prefixExpression.getOperationTokenType(); if (!JavaTokenType.EXCL.equals(prefixTokenType)) { return; } binaryExpression = (PsiBinaryExpression) lhs; possibleInstanceofExpression = ParenthesesUtils.stripParentheses(prefixExpression.getOperand()); } else if (rhs instanceof PsiBinaryExpression && lhs instanceof PsiPrefixExpression) { final PsiPrefixExpression prefixExpression = (PsiPrefixExpression) lhs; final IElementType prefixTokenType = prefixExpression.getOperationTokenType(); if (!JavaTokenType.EXCL.equals(prefixTokenType)) { return; } binaryExpression = (PsiBinaryExpression) rhs; possibleInstanceofExpression = ParenthesesUtils.stripParentheses(prefixExpression.getOperand()); } else { return; } final IElementType tokenType = binaryExpression.getOperationTokenType(); if (!tokenType.equals(JavaTokenType.EQEQ)) { return; } } else { return; } final PsiReferenceExpression referenceExpression1 = getReferenceFromNullCheck(binaryExpression); if (referenceExpression1 == null) { return; } final PsiReferenceExpression referenceExpression2 = getReferenceFromInstanceofExpression(possibleInstanceofExpression); if (!referencesEqual(referenceExpression1, referenceExpression2)) { return; } registerError(binaryExpression); }