Interface Environment

  • All Known Implementing Classes:
    AbstractEnvironment, EnvironmentBase, MpsEnvironment

    public interface Environment
    Intended to be used in headless runs, represents working MPS environment. Currently it is cached for all tests in the case of group test runs (suites). To initialize environment in a lazy way (trying to get cached environment if available) use MPSEnvironment or IdeaEnvironment #getOrCreate methods. Use MPSEnvironment if you do not need the idea platform, IdeaEnvironment otherwise. These methods use ref counting to dispose the environment in the right time (at the end of suite or at the end of the test); they call the method #retain to increase the reference counter. The common pattern in tests is to call #getOrCreate method in the @BeforeClass section, and call #release method in the @AfterClass section. There are helping base classes: PlatformMpsTest and CoreMpsTest for the IdeaEnvironment and MpsEnvironment correspondingly. AP: TODO consider merging all the project creation methods There are two base implementations, EnvironmentBase which is deemed for full-fledged runtime instances, and AbstractEnvironment generally intended for lightweight, API-like access to existing runtime instance.
    • Method Detail

      • createEmptyProject

        @NotNull
        Project createEmptyProject()
        Creates and opens an empty project
        Returns:
        newly created Project.
      • createProject

        @NotNull
        Project createProject​(@NotNull
                              ProjectStrategy strategy)
        Creates a project and opens it according to the given strategy
        Returns:
        newly created Project constructed as the strategy suggests. It is already opened.
      • closeProject

        void closeProject​(@NotNull
                          Project project)
        Discards previously opened project. Environment does its best to close the project but may choose to ignore request in certain scenarions (like in-process test execution, when closing an active project may affect user experience)
        Parameters:
        project - an instance obtained from openProject(java.io.File)
      • dispose

        void dispose()
        disposes the environment for real, does not consider ref counts
      • flushAllEvents

        void flushAllEvents()
        flushes all #invokeAndLater calls and all ModelAccess event queue if needed
      • getPlatform

        Platform getPlatform()
        Returns:
        MPS (its platform aspect) of this tooling environment, not null when initialized.