private void checkForMethodCalls(PsiExpression condition) {
      condition.accept(new JavaRecursiveElementWalkingVisitor() {

          @Override
          public void visitMethodCallExpression(@NotNull PsiMethodCallExpression expression) {
            super.visitMethodCallExpression(expression);
            if (ignoreIterationMethods) {
              if (isIterationMethod(expression) || isCallToCasMethod(expression)) {
                return;
              }
            }
            registerMethodCallError(expression);
          }

        private static boolean isIterationMethod(@NotNull PsiMethodCallExpression expression) {
          return MethodCallUtils.isCallToMethod(expression, CommonClassNames.JAVA_UTIL_ITERATOR, PsiTypes.booleanType(), "hasNext") ||
                 MethodCallUtils.isCallToMethod(expression, "java.util.ListIterator", PsiTypes.booleanType(), "hasPrevious") ||
                 MethodCallUtils.isCallToMethod(expression, "java.sql.ResultSet", PsiTypes.booleanType(), "next") ||
                 MethodCallUtils.isCallToMethod(expression, "java.util.Enumeration", PsiTypes.booleanType(), "hasMoreElements") ||
                 MethodCallUtils.isCallToMethod(expression, CommonClassNames.JAVA_UTIL_QUEUE, null, "poll") ||
                 MethodCallUtils.isCallToMethod(expression, "java.lang.ref.ReferenceQueue", null, "poll");
        }

        private static boolean isCallToCasMethod(@NotNull PsiMethodCallExpression expression) {
          final String methodName = MethodCallUtils.getMethodName(expression);
          if (!"weakCompareAndSet".equals(methodName) && !"compareAndSet".equals(methodName)) {
            return false;
          }
          final PsiMethod method = expression.resolveMethod();
          if (method == null) {
            return false;
          }
          final PsiClass containingClass = method.getContainingClass();
          if (containingClass == null) {
            return false;
          }
          final String qualifiedName = containingClass.getQualifiedName();
          return qualifiedName != null && qualifiedName.startsWith("java.util.concurrent.atomic.");
        }
      });
    }
private void checkForMethodCalls(PsiExpression condition)