PsiElementVisitor (@NotNull ProblemsHolder holder, boolean isOnTheFly) { return new RegExpElementVisitor() { @Override public void visitRegExpClass(RegExpClass regExpClass) { RegExpClassElement[] classElements = regExpClass.getElements(); boolean containsNonWordCharacterClass = ContainerUtil.exists(classElements, RegExpRedundantClassElementInspection::isAnyNonWordCharacter); boolean containsWordCharacterClass = ContainerUtil.exists(classElements, RegExpRedundantClassElementInspection::isAnyWordCharacter); for (RegExpClassElement element : classElements) { if (containsWordCharacterClass && isAnyDigit(element) || containsNonWordCharacterClass && isAnyNonDigit(element)) { String elementText = element.getText(); holder.registerProblem(element, RegExpBundle.message("inspection.warning.redundant.class.element", elementText), new RemoveRedundantClassElement(elementText)); } } } }; }