PsiElementVisitor (@NotNull ProblemsHolder holder, boolean isOnTheFly) { if (!PsiUtil.isLanguageLevel5OrHigher(holder.getFile())) return PsiElementVisitor.EMPTY_VISITOR; return RedundantCastUtil.createRedundantCastVisitor(typeCast -> { ProblemDescriptor descriptor = createDescription(typeCast, holder.getManager(), isOnTheFly); if (descriptor != null) { holder.registerProblem(descriptor); } return true; }); }