PsiElementVisitor (@NotNull final ProblemsHolder holder, boolean isOnTheFly) { return new JavaElementVisitor() { final Pair<String, ? extends Set<String>> annotationName = Configuration.getProjectInstance(holder.getProject()).getAdvancedConfiguration().getPatternAnnotationPair(); @Override public void visitMethod(@NotNull PsiMethod method) { PsiIdentifier psiIdentifier = method.getNameIdentifier(); if (psiIdentifier == null || !PsiUtilEx.isLanguageAnnotationTarget(method)) { return; } PsiAnnotation[] annotationFrom = AnnotationUtilEx.getAnnotationFrom(method, annotationName, true, false); if (annotationFrom.length == 0) { PsiAnnotation[] annotationFromHierarchy = AnnotationUtilEx.getAnnotationFrom(method, annotationName, true, true); if (annotationFromHierarchy.length > 0) { PsiAnnotation annotation = annotationFromHierarchy[annotationFromHierarchy.length - 1]; String annotationClassname = annotation.getQualifiedName(); PsiNameValuePair[] argList = annotation.getParameterList().getAttributes(); holder.registerProblem(psiIdentifier, IntelliLangBundle.message("inspection.pattern.overridden.by.non.annotated.method.description"), new AddAnnotationFix(Objects.requireNonNull(annotationClassname), method, argList)); } } } }; }