Search in sources :

Example 1 with ApplicationManager

use of com.intellij.openapi.application.ApplicationManager in project intellij by bazelbuild.

the class TestUtils method createMockApplication.

public static void createMockApplication(Disposable parentDisposable) {
    final BlazeMockApplication instance = new BlazeMockApplication(parentDisposable);
    // If there was no previous application,
    // ApplicationManager leaves the MockApplication in place, which can break future tests.
    Application oldApplication = ApplicationManager.getApplication();
    if (oldApplication == null) {
        Disposer.register(parentDisposable, () -> {
            new ApplicationManager() {

                {
                    ourApplication = null;
                }
            };
        });
    }
    ApplicationManager.setApplication(instance, FileTypeManager::getInstance, parentDisposable);
    instance.registerService(EncodingManager.class, EncodingManagerImpl.class);
}
Also used : ApplicationManager(com.intellij.openapi.application.ApplicationManager) FileTypeManager(com.intellij.openapi.fileTypes.FileTypeManager) Application(com.intellij.openapi.application.Application)

Aggregations

Application (com.intellij.openapi.application.Application)1 ApplicationManager (com.intellij.openapi.application.ApplicationManager)1 FileTypeManager (com.intellij.openapi.fileTypes.FileTypeManager)1