void (PsiModifierListOwner psiModifierListOwner) { for (RedundantModifiersInfo redundantModifiersInfo : redundantModifiersInfo) { RedundantModifiersInfoType infoType = redundantModifiersInfo.getType(); PsiModifierListOwner parentModifierListOwner = PsiTreeUtil.getParentOfType(psiModifierListOwner, PsiModifierListOwner.class, infoType != RedundantModifiersInfoType.CLASS && infoType != RedundantModifiersInfoType.VARIABLE); if (parentModifierListOwner == null) { continue; } if (infoType == RedundantModifiersInfoType.VARIABLE && !(parentModifierListOwner instanceof PsiLocalVariable || parentModifierListOwner instanceof PsiParameter) || (infoType != RedundantModifiersInfoType.VARIABLE && !(parentModifierListOwner instanceof PsiClass))) { continue; } if ((supportedAnnotation == null || parentModifierListOwner.hasAnnotation(supportedAnnotation)) && redundantModifiersInfo.getType().getSupportedClass().isAssignableFrom(psiModifierListOwner.getClass())) { PsiModifierList psiModifierList = psiModifierListOwner.getModifierList(); if (psiModifierList == null || (redundantModifiersInfo.getDontRunOnModifier() != null && psiModifierList.hasExplicitModifier(redundantModifiersInfo.getDontRunOnModifier()))) { continue; } if (!redundantModifiersInfo.shouldCheck(psiModifierListOwner)) { continue; } for (String modifier : redundantModifiersInfo.getModifiers()) { if (psiModifierList.hasExplicitModifier(modifier)) { final Optional<PsiElement> psiModifier = Arrays.stream(psiModifierList.getChildren()) .filter(psiElement -> modifier.equals(psiElement.getText())) .findFirst(); psiModifier.ifPresent(psiElement -> holder.registerProblem(psiElement, redundantModifiersInfo.getDescription(), ProblemHighlightType.WARNING, new RemoveModifierFix(modifier)) ); } } } } }