PsiElementVisitor (@NotNull ProblemsHolder holder, boolean isOnTheFly) { if (!HighlightingFeature.PATTERN_GUARDS_AND_RECORD_PATTERNS.isAvailable(holder.getFile())) return PsiElementVisitor.EMPTY_VISITOR; return new JavaElementVisitor() { @Override public void visitInstanceOfExpression(@NotNull PsiInstanceOfExpression expression) { PsiPrimaryPattern pattern = expression.getPattern(); if (pattern instanceof PsiDeconstructionPattern) return; PsiPatternVariable variable = JavaPsiPatternUtil.getPatternVariable(pattern); if (variable == null) return; List<List<PsiReferenceExpression>> collect = collect(expression, variable, false); if (collect.isEmpty()) return; holder.registerProblem(variable.getTypeElement(), InspectionGadgetsBundle.message("inspection.deconstruction.can.be.used.message"), new PatternVariableCanBeUsedFix()); } }; }