com.intellij.openapi.application.ApplicationManager.setApplication()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(6.0k)|赞(0)|评价(0)|浏览(103)

本文整理了Java中com.intellij.openapi.application.ApplicationManager.setApplication()方法的一些代码示例,展示了ApplicationManager.setApplication()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ApplicationManager.setApplication()方法的具体详情如下:
包路径:com.intellij.openapi.application.ApplicationManager
类名称:ApplicationManager
方法名:setApplication

ApplicationManager.setApplication介绍

暂无

代码示例

代码示例来源:origin: JetBrains/Grammar-Kit

public static MockApplicationEx initApplication(Disposable rootDisposable) {
 MockApplicationEx instance = new MockApplicationEx(rootDisposable);
 ApplicationManager.setApplication(instance, FileTypeManager::getInstance, rootDisposable);
 instance.registerService(EncodingManager.class, EncodingManagerImpl.class);
 return instance;
}

代码示例来源:origin: groboclown/p4ic4idea

@Override
public void afterEach(ExtensionContext extensionContext) {
  Application app = (Application) getStore(extensionContext).get("original-application");
  if (app != null) {
    ApplicationManager.setApplication(
        app,
        new DisposableRegistry());
  }
  contextStack.remove(0);
}

代码示例来源:origin: GoogleCloudPlatform/google-cloud-intellij

@After
public void tearDown() {
 ApplicationManager.setApplication(application, disposable);
}

代码示例来源:origin: GoogleCloudPlatform/google-cloud-intellij

/**
 * For every #createMockApplication there needs to be a corresponding call to
 * #disposeMockApplication when the test is complete.
 */
public static Disposable createMockApplication() {
 Disposable parentDisposable = getParentDisposableForCleanup();
 final PluginMockApplication instance = new PluginMockApplication(parentDisposable);
 ApplicationManager.setApplication(
   instance,
   new Getter<FileTypeRegistry>() {
    @Override
    public FileTypeRegistry get() {
     return FileTypeManager.getInstance();
    }
   },
   parentDisposable);
 instance.registerService(EncodingManager.class, EncodingManagerImpl.class);
 return parentDisposable;
}

代码示例来源:origin: GoogleCloudPlatform/google-cloud-intellij

@Test
public void testInitComponent_usageTrackingIsDisabled() {
 Application mockApplication = spy(ApplicationManager.getApplication());
 when(mockApplication.isUnitTestMode()).thenReturn(true);
 ApplicationManager.setApplication(mockApplication, disposable);
 testComponent = spy(new CloudToolsPluginInitializationComponent());
 testComponent.initComponent();
 verify(testComponent, never()).configureUsageTracking();
}

代码示例来源:origin: groboclown/p4ic4idea

@Override
public void beforeEach(ExtensionContext extensionContext) {
  contextStack.add(0, extensionContext);
  DisposableRegistry parent = new DisposableRegistry();
  getStore(extensionContext).put("parent", parent);
  final FileTypeRegistry fileTypeRegistry = mock(FileTypeRegistry.class);
  getStore(extensionContext).put("fileTypeRegistry", fileTypeRegistry);
  Application original = ApplicationManager.getApplication();
  getStore(extensionContext).put("original-application", original);
  Application application = mock(Application.class);
  ApplicationManager.setApplication(application, () -> fileTypeRegistry, parent);
  getStore(extensionContext).put("application", application);
  initializeApplication(application);
  Project project = mock(Project.class);
  when(project.isInitialized()).thenReturn(true);
  when(project.isDisposed()).thenReturn(false);
  getStore(extensionContext).put("project", project);
  initializeProject(project);
  LocalFileSystem lfs = mock(LocalFileSystem.class);
  getStore(extensionContext).put("local-filesystem", lfs);
  setupLocalFileSystem(lfs);
}

代码示例来源:origin: GoogleCloudPlatform/google-cloud-intellij

@Test
public void testInitComponent_usageTrackingIsEnabled() {
 Application mockApplication = spy(ApplicationManager.getApplication());
 when(mockApplication.isUnitTestMode()).thenReturn(false);
 ApplicationManager.setApplication(mockApplication, disposable);
 testComponent = spy(new CloudToolsPluginInitializationComponent());
 doNothing().when(testComponent).configureUsageTracking();
 testComponent.initComponent();
 verify(testComponent).configureUsageTracking();
}

代码示例来源:origin: SonarSource/sonarlint-intellij

@Before
public final void setUp() {
 ApplicationManager.setApplication(app, mock(Disposable.class));
 when(app.isUnitTestMode()).thenReturn(true);
 when(app.getMessageBus()).thenReturn(new MessageBusImpl.RootBus(this));
 when(app.isHeadlessEnvironment()).thenReturn(true);
 when(app.acquireReadActionLock()).thenReturn(mock(AccessToken.class));
 when(app.getMessageBus()).thenReturn(new MessageBusImpl.RootBus(this));
 Answer<Void> runArg = invocation -> {
  ((ThrowableComputable) invocation.getArgument(0)).compute();
  return null;
 };
 doAnswer(runArg).when(app).runReadAction(any(ThrowableComputable.class));
 register(app, CertificateManager.class, new CertificateManager());
 createModuleRoot();
}

代码示例来源:origin: GoogleCloudPlatform/google-cloud-intellij

@Before
public void setUp() {
 MockApplication application = new MyMockApplicationEx(parent);
 ActionManagerEx manager = Mockito.mock(ActionManagerEx.class);
 ActionToolbar actionToolbar = Mockito.mock(ActionToolbar.class);
 Mockito.when(actionToolbar.getComponent()).thenReturn(new JComponent() {});
 Mockito.when(
     manager.createActionToolbar(
       Mockito.anyString(), Mockito.any(ActionGroup.class), Mockito.anyBoolean()))
   .thenReturn(actionToolbar);
 Mockito.when(
     manager.createActionToolbar(
       Mockito.anyString(),
       Mockito.any(ActionGroup.class),
       Mockito.anyBoolean(),
       Mockito.anyBoolean()))
   .thenReturn(actionToolbar);
 application.addComponent(ActionManager.class, manager);
 application.registerService(UISettings.class);
 ApplicationManager.setApplication(application, parent);
 XDebugSession session = Mockito.mock(XDebugSession.class);
 Mockito.when(handler.getProcess()).thenReturn(mockProcess);
 Mockito.when(mockProcess.getXDebugSession()).thenReturn(session);
}

代码示例来源:origin: PavlikPolivka/GitLabProjects

@Before
public void setUp() throws Exception {
 ApplicationManager.setApplication(new DummyApplication(settingsState), new DummyDisposable());
}

代码示例来源:origin: PavlikPolivka/GitLabProjects

@Before
public void setUp() throws Exception {
  settingsState = new DummySettingState();
  ApplicationManager.setApplication(new DummyApplication(settingsState), new DummyDisposable());
  gitLabProjectMatcher = new GitLabProjectMatcher();
}

相关文章