IDEA-129708 action "Annotate method foo as NotNull" missed

This commit is contained in:
peter
2014-09-11 18:52:41 +02:00
parent bf1fc6e761
commit a571db269e
@@ -56,9 +56,11 @@ public abstract class AddAnnotationIntention extends BaseIntentionAction {
Pair<String, String[]> annotations = getAnnotations(project);
String toAdd = annotations.first;
String[] toRemove = annotations.second;
if (toRemove.length > 0 && AnnotationUtil.isAnnotated(owner, toRemove[0], false, false)) return false;
if (toRemove.length > 0 && isAnnotatedSkipInferred(owner, toRemove)) {
return false;
}
setText(AddAnnotationPsiFix.calcText(owner, toAdd));
if (AnnotationUtil.isAnnotated(owner, toAdd, false, false)) return false;
if (isAnnotatedSkipInferred(owner, toAdd)) return false;
if (owner instanceof PsiMethod) {
PsiType returnType = ((PsiMethod)owner).getReturnType();
@@ -73,6 +75,11 @@ public abstract class AddAnnotationIntention extends BaseIntentionAction {
return true;
}
private static boolean isAnnotatedSkipInferred(PsiModifierListOwner owner, String... annoFqns) {
PsiAnnotation annotation = AnnotationUtil.findAnnotation(owner, false, annoFqns);
return annotation != null && !AnnotationUtil.isInferredAnnotation(annotation);
}
@Override
public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
PsiModifierListOwner owner = AddAnnotationPsiFix.getContainer(file, editor.getCaretModel().getOffset());