@Override
    protected void applyFix(@NotNull Project project, @NotNull PsiElement element, @NotNull ModPsiUpdater updater) {
      PsiSwitchBlock block = PsiTreeUtil.getParentOfType(element, PsiSwitchBlock.class);
      if (block == null) return;
      List<PsiExpression> branches = extractBranches(block);
      if (branches == null) return;
      PsiExpression[] diffs = findDiffs(block, branches);
      if (diffs.length == 0) return;

      PsiElementFactory factory = JavaPsiFacade.getElementFactory(project);
      PsiSwitchExpression newSwitch =
        (PsiSwitchExpression)factory.createExpressionFromText("switch(x) {}", block);
      PsiExpression selector = block.getExpression();
      PsiExpression newSelector = Objects.requireNonNull(newSwitch.getExpression());
      if (selector == null) {
        newSelector.delete();
      } else {
        newSelector.replace(selector);
      }
      Objects.requireNonNull(newSwitch.getBody()).replace(Objects.requireNonNull(block.getBody()));
      List<PsiExpression> newBranches = Objects.requireNonNull(extractBranches(newSwitch));
      for (int i = 0; i < newBranches.size(); i++) {
        newBranches.get(i).replace(diffs[i]);
      }
      diffs[0].replace(newSwitch);
      PsiExpression expression = branches.get(0);
      if (block instanceof PsiSwitchExpression) {
        block.replace(expression);
      } else {
        PsiExpressionStatement newStatement = (PsiExpressionStatement)factory.createStatementFromText("x;", block);
        newStatement.getExpression().replace(expression);
        block.replace(newStatement);
      }
    }
@Override
    protected void applyFix(@NotNull Project project, @NotNull PsiElement element, @NotNull ModPsiUpdater updater)