List<AccessModifier> (@NotNull PsiMember member) { PsiClass containingClass = member.getContainingClass(); if (member instanceof PsiField) { if (member instanceof PsiEnumConstant || containingClass == null || containingClass.isInterface()) return Collections.emptyList(); return ALL_MODIFIERS; } if (member instanceof PsiMethod) { PsiMethod method = (PsiMethod)member; if (containingClass == null || containingClass.isEnum() && method.isConstructor()) return Collections.emptyList(); if (JavaPsiRecordUtil.getRecordComponentForAccessor(method) != null) { return Collections.singletonList(PUBLIC); } if (JavaPsiRecordUtil.isCompactConstructor(method) || JavaPsiRecordUtil.isExplicitCanonicalConstructor(method) || method instanceof LightRecordCanonicalConstructor) { PsiModifierList list = containingClass.getModifierList(); if (list != null) { AccessModifier classModifier = fromModifierList(list); return ContainerUtil.filter(ALL_MODIFIERS, m -> !classModifier.isWeaker(m)); } return Collections.singletonList(PUBLIC); } if (containingClass.isInterface()) { if (method.getBody() != null && PsiUtil.isLanguageLevel9OrHigher(member)) { return PUBLIC_PRIVATE; } return Collections.singletonList(PUBLIC); } AccessModifier minAccess = getMinAccess(method); if (minAccess != PRIVATE) { return ContainerUtil.filter(ALL_MODIFIERS, mod -> mod.compareTo(minAccess) <= 0); } return ALL_MODIFIERS; } if (member instanceof PsiClass) { if (PsiUtil.isLocalOrAnonymousClass((PsiClass)member)) return Collections.emptyList(); if (containingClass == null) return PUBLIC_PACKAGE; return ALL_MODIFIERS; } return Collections.emptyList(); }