private static boolean containsError(PsiAnnotation annotation) {
      final PsiJavaCodeReferenceElement nameRef = annotation.getNameReferenceElement();
      if (nameRef == null) {
        return true;
      }
      final PsiClass aClass = (PsiClass) nameRef.resolve();
      if (aClass == null || !aClass.isAnnotationType()) {
        return true;
      }
      final Set<String> names = new HashSet<String>();
      final PsiAnnotationParameterList annotationParameterList = annotation.getParameterList();
      if (PsiUtilCore.hasErrorElementChild(annotationParameterList)) {
        return true;
      }
      final PsiNameValuePair[] attributes = annotationParameterList.getAttributes();
      for (PsiNameValuePair attribute : attributes) {
        final PsiReference reference = attribute.getReference();
        if (reference == null) {
          return true;
        }
        final PsiMethod method = (PsiMethod) reference.resolve();
        if (method == null) {
          return true;
        }
        final PsiAnnotationMemberValue value = attribute.getValue();
        if (value == null || PsiUtilCore.hasErrorElementChild(value)) {
          return true;
        }
        if (value instanceof PsiAnnotation && containsError((PsiAnnotation) value)) {
          return true;
        }
        if (!hasCorrectType(value, method.getReturnType())) {
          return true;
        }
        final String name = attribute.getName();
        if (!names.add(name != null ? name : PsiAnnotation.DEFAULT_REFERENCED_METHOD_NAME)) {
          return true;
        }
      }

      for (PsiMethod method : aClass.getMethods()) {
        if (!(method instanceof PsiAnnotationMethod)) {
          continue;
        }
        final PsiAnnotationMethod annotationMethod = (PsiAnnotationMethod) method;
        if (annotationMethod.getDefaultValue() == null
            && !names.contains(annotationMethod.getName())) {
          return true; // missing a required argument
        }
      }
      return false;
    }
 @Override
 public void visitExpressionStatement(@NotNull PsiExpressionStatement statement) {
   super.visitExpressionStatement(statement);
   final PsiExpression expression = statement.getExpression();
   if (!(expression instanceof PsiMethodCallExpression)) {
     return;
   }
   final PsiMethodCallExpression call = (PsiMethodCallExpression) expression;
   final PsiMethod method = call.resolveMethod();
   if (method == null || method.isConstructor()) {
     return;
   }
   final PsiType returnType = method.getReturnType();
   if (PsiType.VOID.equals(returnType)) {
     return;
   }
   final PsiClass aClass = method.getContainingClass();
   if (aClass == null) {
     return;
   }
   if (PsiUtilCore.hasErrorElementChild(statement)) {
     return;
   }
   if (m_reportAllNonLibraryCalls && !LibraryUtil.classIsInLibrary(aClass)) {
     registerMethodCallError(call, aClass);
     return;
   }
   final PsiReferenceExpression methodExpression = call.getMethodExpression();
   final String methodName = methodExpression.getReferenceName();
   if (methodName == null) {
     return;
   }
   for (int i = 0; i < methodNamePatterns.size(); i++) {
     final String methodNamePattern = methodNamePatterns.get(i);
     if (!methodNamesMatch(methodName, methodNamePattern)) {
       continue;
     }
     final String className = classNames.get(i);
     if (!InheritanceUtil.isInheritor(aClass, className)) {
       continue;
     }
     registerMethodCallError(call, aClass);
     return;
   }
 }