public static void runTypeMigrationOnVariable(@NotNull PsiVariable variable,
                                                @NotNull PsiType targetType,
                                                @Nullable Editor editor,
                                                boolean optimizeImports,
                                                boolean allowDependentRoots) {
    Project project = variable.getProject();
    if (!FileModificationService.getInstance().prepareFileForWrite(variable.getContainingFile())) return;
    try {
      WriteAction.run(() -> variable.normalizeDeclaration());
      final TypeMigrationRules rules = new TypeMigrationRules(project);
      rules.setBoundScope(variable.getUseScope());
      TypeMigrationProcessor.runHighlightingTypeMigration(project, editor, rules, variable, targetType, optimizeImports, allowDependentRoots);
      WriteAction.run(() -> JavaCodeStyleManager.getInstance(project).shortenClassReferences(variable));
      UndoUtil.markPsiFileForUndo(variable.getContainingFile());
    }
    catch (IncorrectOperationException e) {
      LOG.error(e);
    }
  }
public static void runTypeMigrationOnVariable(@NotNull PsiVariable variable,
                                                @NotNull PsiType targetType,
                                                @Nullable Editor editor,
                                                boolean optimizeImports,
                                                boolean allowDependentRoots)