@Override
  public @NotNull PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) {
    return new JavaElementVisitor() {
      @Override
      public void visitSwitchExpression(@NotNull PsiSwitchExpression expression) {
        processBlock(expression);
      }

      @Override
      public void visitSwitchStatement(@NotNull PsiSwitchStatement statement) {
        processBlock(statement);
      }

      private void processBlock(PsiSwitchBlock block) {
        List<PsiExpression> branches = extractBranches(block);
        if (branches == null) return;
        PsiExpression[] diffs = findDiffs(block, branches);
        if (diffs.length != 0) {
          holder.registerProblem(block.getFirstChild(),
                                 InspectionGadgetsBundle.message("inspection.common.subexpression.in.switch.display.name"),
                                 new PushDownSwitchExpressionFix());
        }
      }
    };
  }
@Override
  public @NotNull PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly)