boolean (PsiElement position) { if (psiElement(PsiIdentifier.class) .withParents(PsiJavaCodeReferenceElement.class, PsiAnnotation.class, PsiModifierList.class).accepts(position)) { PsiElement parent = Objects.requireNonNull(PsiTreeUtil.getParentOfType(position, PsiModifierList.class)).getParent(); if (parent instanceof PsiClass) { return true; } if (parent instanceof PsiMethod || parent instanceof PsiField) { PsiAnnotation anno = Objects.requireNonNull(PsiTreeUtil.getParentOfType(position, PsiAnnotation.class)); return anno.getTextRange().getStartOffset() == parent.getTextRange().getStartOffset() && isFollowedByEol(anno); } } return false; }