mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-06 06:21:16 +07:00
IDEA-129708 action "Annotate method foo as NotNull" missed
This commit is contained in:
+9
-2
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user