@Override
    protected void applyFix(@NotNull Project project, @NotNull PsiElement element, @NotNull ModPsiUpdater updater) {
      PsiPatternVariable patternVariable = ObjectUtils.tryCast(element.getParent(), PsiPatternVariable.class);
      if (patternVariable == null) return;
      PsiInstanceOfExpression instanceOf = ObjectUtils.tryCast(patternVariable.getParent().getParent(), PsiInstanceOfExpression.class);
      if (instanceOf == null) return;
      List<List<PsiReferenceExpression>> collect = collect(instanceOf, patternVariable, true);
      StringJoiner deconstructionList = new StringJoiner(", ", "(", ")");
      for (List<PsiReferenceExpression> expressions : collect) {
        PsiReferenceExpression firstRef = expressions.get(0);
        PsiType type = firstRef.getType();
        String s = StringUtil.substringAfter(firstRef.getText(), ".");
        VariableNameGenerator generator = new VariableNameGenerator(patternVariable, VariableKind.PARAMETER).byName(s);
        s = generator.generate(false);
        deconstructionList.add((type != null ? type.getCanonicalText() : "var") + " " + s);
        for (PsiReferenceExpression expression : expressions) {
          PsiLocalVariable variable = getVariableFromInitializer(expression);
          if (variable != null) {
            var references = VariableAccessUtils.getVariableReferences(variable);
            for (PsiReferenceExpression ref : references) {
              ExpressionUtils.bindReferenceTo(ref, s);
            }
            new CommentTracker().deleteAndRestoreComments(variable);
          }
          else {
            new CommentTracker().replace(expression.getParent() instanceof PsiMethodCallExpression call ? call : expression, s);
          }
        }
      }

      PsiInstanceOfExpression replace =
        (PsiInstanceOfExpression)new CommentTracker().replace(instanceOf, instanceOf.getOperand().getText() +
                                                                          " instanceof " +
                                                                          element.getText() + deconstructionList + patternVariable.getName());
      PsiPrimaryPattern pattern = replace.getPattern();
      PsiPatternVariable variable = JavaPsiPatternUtil.getPatternVariable(pattern);
      assert variable != null;
      if (!VariableAccessUtils.variableIsUsed(variable, variable.getDeclarationScope())) {
        new CommentTracker().replace(replace, replace.getOperand().getText() +
                                              " instanceof " +
                                              element.getText() + deconstructionList);
      }
    }
@Override
    protected void applyFix(@NotNull Project project, @NotNull PsiElement element, @NotNull ModPsiUpdater updater)