Skip to content

What Happens on MPS Startup

This page looks behind the hood of the startup process of MPS 2021.1.4 and newer. For most parts, similar code executes for other MPS versions.

The application starts with Launcher.java ⧉, setting some IntelliJ-specific properties, such as the file watcher path and the platform prefix, and collecting the plugin paths when running MPS from sources. It then calls Main.kt ⧉, where it sets flags about the execution environment, such as the headless mode or if the application is invoked from the command line. The system properties are also loaded and populated with data. BootstrapClassLoaderUtil#initClassLoader() loads the class loader. Afterward, MainImpl.kt ⧉ is looked up and executed. It mainly redirects the application's initialization to the ApplicationLoader#initApplication ⧉ method. The time from this method to ApplicationLoader.run is called app initialization. Here, the command line arguments are first processed: a special method looks for -Dkey=value program arguments and stores some of them in system properties. A task on the event dispatch thread initializes the GUI and loads system fonts. Plugins are also initialized and loaded.

You can start MPS from MPS itself through MPSEnvironment.java or IdeaEnvironment.java from outside. EnvironmentConfig Both initialize both classes. It also lets you specify the plugins, macros, and libraries that should be loaded. In IdeaEnvironment#createIdeaApplication ⧉, some IntelliJ-specific properties are also set. Both environments can manage MPS projects (creating, opening, and closing them).

For the integration with the IntelliJ platform, MPSCoreComponents ⧉ plays an important role: it contains references to the following core components:

  • MPS platform with the base class PlatformBase ⧉
  • PersistenceRegistry.java as the core component implementation of PersistenceFacade ⧉. The PersistenceFacade represents a singleton registry of models, model root factories, find usages, and navigation participants. It also provides methods to transform strings to model refs/module refs/node IDs and vice versa.
  • LibraryInitializer.java, which manages library contributions (loading, unloading, updating). It creates instances of SLibrary for each path RepositoryContributor#getPaths() returns. SLibrary tracks a path with modules inside. It listens to file system events and reloads modules from the disk if necessary. It is the layer between SRepository and SModule ⧉ in the repository hierarchy (as well as the project). The repository consists of library modules, project modules, and several special modules.
  • ClassLoaderManager.java ⧉ is responsible for loading classes within MPS.

MPS Platform

The MPS platform contains so-called component plugins that are registered through PlatformBase:

MPSCore

This class provides the following core components:

Comments