@Override public void visitMethodCallExpression(@NotNull PsiMethodCallExpression expression) { super.visitMethodCallExpression(expression); final PsiReferenceExpression methodExpression = expression.getMethodExpression(); @NonNls final String methodName = methodExpression.getReferenceName(); if (methodName == null) { return; } if (!methodName.startsWith("get") && !methodName.startsWith("update")) { return; } final PsiExpressionList argumentList = expression.getArgumentList(); final PsiExpression[] arguments = argumentList.getExpressions(); if (arguments.length == 0) { return; } final PsiExpression argument = arguments[0]; if (!TypeUtils.expressionHasType(argument, PsiKeyword.INT)) { return; } if (!PsiUtil.isConstantExpression(argument)) { return; } final Integer val = (Integer) ConstantExpressionUtil.computeCastTo(argument, PsiType.INT); if (val == null || val.intValue() != 0) { return; } final PsiExpression qualifier = methodExpression.getQualifierExpression(); if (!TypeUtils.expressionHasTypeOrSubtype(qualifier, "java.sql.ResultSet")) { return; } registerError(argument); }
private static boolean isCharacter(PsiExpression expression) { return TypeUtils.expressionHasType(expression, PsiKeyword.CHAR) || TypeUtils.expressionHasType(expression, CommonClassNames.JAVA_LANG_CHARACTER); }