package jetbrains.mps.ide.mpsmigration;

/*Generated by MPS */

import jetbrains.mps.plugins.part.ApplicationPluginPart;
import java.util.ArrayDeque;
import jetbrains.mps.migration.global.ProjectMigration;
import jetbrains.mps.migration.global.ProjectMigrationsRegistry;
import jetbrains.mps.ide.mpsmigration.v_2017_1.Migrations_2017_1;
import jetbrains.mps.ide.mpsmigration.v_2017_2.Migrations_2017_2;
import jetbrains.mps.ide.mpsmigration.v_2018_2.Migrations_2018_2;
import jetbrains.mps.ide.mpsmigration.v_2019_1.Migrations_2019_1;
import jetbrains.mps.ide.mpsmigration.v_2019_3.Migrations_2019_3;
import jetbrains.mps.ide.mpsmigration.v_2021_2.Migrations_2021_2;
import jetbrains.mps.ide.mpsmigration.v_2021_3.Migrations_2021_3;
import jetbrains.mps.ide.mpsmigration.v_2022_3.Migrations_2022_3;
import jetbrains.mps.ide.mpsmigration.v_2023_1.Migrations_2023_1;

public class ProjectMigrations_AppPluginPart extends ApplicationPluginPart {
  private ArrayDeque<ProjectMigration> myMigrations = new ArrayDeque<ProjectMigration>();
  private ProjectMigrationsRegistry myRegistry;
  public ProjectMigrations_AppPluginPart() {
  }
  @Override
  public void init() {
    ProjectMigrations_AppPluginPart.this.myRegistry = ProjectMigrationsRegistry.getInstance();
    // block of migrations. In fact, there's no need to use dedicated Migrations_XXX class,
    // it's just the way it used to be when individual AppComponents served as a registration mechanism.
    new Migrations_2017_1().offerInto(ProjectMigrations_AppPluginPart.this.myMigrations);
    new Migrations_2017_2().offerInto(ProjectMigrations_AppPluginPart.this.myMigrations);
    new Migrations_2018_2().offerInto(ProjectMigrations_AppPluginPart.this.myMigrations);
    new Migrations_2019_1().offerInto(ProjectMigrations_AppPluginPart.this.myMigrations);
    new Migrations_2019_3().offerInto(ProjectMigrations_AppPluginPart.this.myMigrations);
    new Migrations_2021_2().offerInto(ProjectMigrations_AppPluginPart.this.myMigrations);
    new Migrations_2021_3().offerInto(ProjectMigrations_AppPluginPart.this.myMigrations);
    new Migrations_2022_3().offerInto(ProjectMigrations_AppPluginPart.this.myMigrations);
    new Migrations_2023_1().offerInto(ProjectMigrations_AppPluginPart.this.myMigrations);
    // assume myMigrations are ordered from older to new
    for (ProjectMigration pm : ProjectMigrations_AppPluginPart.this.myMigrations) {
      ProjectMigrations_AppPluginPart.this.myRegistry.addProjectMigration(pm);
    }
  }
  @Override
  public void dispose() {
    // unregister in reverse order, just for fun
    while (!(ProjectMigrations_AppPluginPart.this.myMigrations.isEmpty())) {
      ProjectMigrations_AppPluginPart.this.myRegistry.removeProjectMigration(ProjectMigrations_AppPluginPart.this.myMigrations.removeLast());
    }
    ProjectMigrations_AppPluginPart.this.myRegistry = null;
  }
}
