diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/AnnotateMethodFix.java b/java/java-analysis-impl/src/com/intellij/codeInspection/AnnotateMethodFix.java index f035b07a2317..88c679bfa509 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/AnnotateMethodFix.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/AnnotateMethodFix.java @@ -19,7 +19,6 @@ import com.intellij.codeInsight.AnnotationUtil; import com.intellij.codeInsight.FileModificationService; import com.intellij.codeInsight.intention.AddAnnotationPsiFix; import com.intellij.openapi.command.undo.UndoUtil; -import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiMethod; @@ -37,7 +36,6 @@ import java.util.List; * @author cdr */ public class AnnotateMethodFix implements LocalQuickFix { - private static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.AnnotateMethodFix"); protected final String myAnnotation; private final String[] myAnnotationsToRemove; @@ -68,7 +66,7 @@ public class AnnotateMethodFix implements LocalQuickFix { List superMethodSignatures = method.findSuperMethodSignaturesIncludingStatic(true); for (MethodSignatureBackedByPsiMethod superMethodSignature : superMethodSignatures) { PsiMethod superMethod = superMethodSignature.getMethod(); - if (!AnnotationUtil.isAnnotated(superMethod, myAnnotation, false, false, true, null) && + if (!AnnotationUtil.isAnnotated(superMethod, myAnnotation, false, false, true) && superMethod.getManager().isInProject(superMethod)) { int ret = shouldAnnotateBaseMethod(method, superMethod, project); if (ret != 0 && ret != 1) return; @@ -81,7 +79,7 @@ public class AnnotateMethodFix implements LocalQuickFix { PsiMethod[] methods = OverridingMethodsSearch.search(method).toArray(PsiMethod.EMPTY_ARRAY); for (PsiMethod psiMethod : methods) { if (AnnotationUtil.isAnnotatingApplicable(psiMethod, myAnnotation) && - !AnnotationUtil.isAnnotated(psiMethod, myAnnotation, false, false, true, null) && + !AnnotationUtil.isAnnotated(psiMethod, myAnnotation, false, false, true) && psiMethod.getManager().isInProject(psiMethod)) { toAnnotate.add(psiMethod); } diff --git a/java/java-psi-api/src/com/intellij/codeInsight/AnnotationUtil.java b/java/java-psi-api/src/com/intellij/codeInsight/AnnotationUtil.java index c95290a2d1e7..041a8f5036b4 100644 --- a/java/java-psi-api/src/com/intellij/codeInsight/AnnotationUtil.java +++ b/java/java-psi-api/src/com/intellij/codeInsight/AnnotationUtil.java @@ -257,25 +257,25 @@ public class AnnotationUtil { } public static boolean isAnnotated(@NotNull PsiModifierListOwner listOwner, @NotNull String annotationFQN, boolean checkHierarchy) { - return isAnnotated(listOwner, annotationFQN, checkHierarchy, true, null); + return isAnnotated(listOwner, annotationFQN, checkHierarchy, true, true, null); } public static boolean isAnnotated(@NotNull PsiModifierListOwner listOwner, @NotNull String annotationFQN, boolean checkHierarchy, boolean skipExternal) { - return isAnnotated(listOwner, annotationFQN, checkHierarchy, skipExternal, null); - } - - private static boolean isAnnotated(@NotNull PsiModifierListOwner listOwner, - @NotNull String annotationFQN, - boolean checkHierarchy, - boolean skipExternal, - @Nullable Set processed) { - return isAnnotated(listOwner, annotationFQN, checkHierarchy, skipExternal, skipExternal, processed); + return isAnnotated(listOwner, annotationFQN, checkHierarchy, skipExternal, skipExternal); } public static boolean isAnnotated(@NotNull PsiModifierListOwner listOwner, + @NotNull String annotationFQN, + boolean checkHierarchy, + boolean skipExternal, + boolean skipInferred) { + return isAnnotated(listOwner, annotationFQN, checkHierarchy, skipExternal, skipInferred, null); + } + + private static boolean isAnnotated(@NotNull PsiModifierListOwner listOwner, @NotNull String annotationFQN, boolean checkHierarchy, boolean skipExternal, @@ -318,7 +318,7 @@ public class AnnotationUtil { if (!processed.add(method)) return false; final PsiMethod[] superMethods = method.findSuperMethods(); for (PsiMethod superMethod : superMethods) { - if (isAnnotated(superMethod, annotationFQN, true, skipExternal, processed)) return true; + if (isAnnotated(superMethod, annotationFQN, true, skipExternal, skipInferred, processed)) return true; } } else if (listOwner instanceof PsiClass) { @@ -327,7 +327,7 @@ public class AnnotationUtil { if (!processed.add(clazz)) return false; final PsiClass[] superClasses = clazz.getSupers(); for (PsiClass superClass : superClasses) { - if (isAnnotated(superClass, annotationFQN, true, skipExternal, processed)) return true; + if (isAnnotated(superClass, annotationFQN, true, skipExternal, skipInferred, processed)) return true; } } }