FixData (@NotNull ModPsiUpdater updater, PsiElement element) { final PsiElement parent = element.getParent(); final PsiElement grandParent = parent.getParent(); if (!(grandParent instanceof PsiMember member)) return null; final PsiModifierList modifierList = member.getModifierList(); if (modifierList == null) return null; final PsiModifierList modifierListCopy = (PsiModifierList)modifierList.copy(); modifierListCopy.setModifierProperty(PsiModifier.PRIVATE, true); final boolean canBePrivate = ReferencesSearch.search(member, member.getUseScope()).allMatch( reference -> JavaResolveUtil.isAccessible(member, member.getContainingClass(), modifierListCopy, reference.getElement(), findAccessObjectClass(reference, member), null)); return new FixData(canBePrivate, updater.getWritable(modifierList)); }