boolean (@Nullable PsiModifierListOwner owner) { if (owner instanceof PsiPackage || owner instanceof PsiClass) return true; if (owner instanceof PsiParameter) { owner = PsiTreeUtil.getParentOfType(owner, PsiMethod.class, true); } if (owner instanceof PsiField || owner instanceof PsiMethod) { return PsiTreeUtil.getParentOfType(owner, PsiClass.class, true) != null; } return false; }