@Override
    protected void applyFix(@NotNull Project project, @NotNull PsiElement element, @NotNull ModPsiUpdater updater) {
      if (!(element.getParent() instanceof PsiLocalVariable variable)) return;
      PsiTypeCastExpression cast = ObjectUtils.tryCast(PsiUtil.skipParenthesizedExprDown(variable.getInitializer()),
                                                       PsiTypeCastExpression.class);
      if (cast == null) return;
      PsiTypeElement typeElement = cast.getCastType();
      if (typeElement == null) return;
      PsiInstanceOfExpression instanceOf = PsiTreeUtil.findSameElementInCopy(myInstanceOfPointer.getElement(), element.getContainingFile());
      if (instanceOf == null) return;
      PsiTypeElement instanceOfType = instanceOf.getCheckType();
      if (instanceOfType != null && instanceOfType.getType() instanceof PsiClassType classType && !classType.isRaw()) {
        typeElement = instanceOfType;
      }
      CommentTracker ct = new CommentTracker();
      StringBuilder text = generateTextForInstanceOf(variable, ct, instanceOf, typeElement);
      if (text == null) return;
      PsiElement replaced = ct.replace(instanceOf, text.toString());
      ct.deleteAndRestoreComments(variable);
      if (!(replaced instanceof PsiInstanceOfExpression instanceOfExpression)) {
        return;
      }
      PsiPrimaryPattern pattern = instanceOfExpression.getPattern();
      if (!(pattern instanceof PsiTypeTestPattern typeTestPattern)) {
        return;
      }
      PsiPatternVariable patternVariable = typeTestPattern.getPatternVariable();
      PsiElement scope = JavaSharedImplUtil.getPatternVariableDeclarationScope(instanceOfExpression);
      boolean nameDeclaredInside = InstanceOfUtils.isConflictingNameDeclaredInside(patternVariable, scope, true);
      if (!nameDeclaredInside) {
        return;
      }
      final JavaCodeStyleManager codeStyleManager = JavaCodeStyleManager.getInstance(project);
      List<String> names = new VariableNameGenerator(instanceOfExpression, VariableKind.LOCAL_VARIABLE)
        .byType(patternVariable.getType()).byName(
          codeStyleManager.suggestUniqueVariableName(patternVariable.getName(), instanceOfExpression, true)).generateAll(true);
      updater.rename(patternVariable, names);
    }
@Override
    protected void applyFix(@NotNull Project project, @NotNull PsiElement element, @NotNull ModPsiUpdater updater)