Search in sources :

Example 6 with ExtensionsArea

use of com.intellij.openapi.extensions.ExtensionsArea in project intellij-community by JetBrains.

the class PathMacroManagerTest method setupApplication.

@Before
public final void setupApplication() throws Exception {
    context = new JUnit4Mockery();
    context.setImposteriser(ClassImposteriser.INSTANCE);
    myApplication = context.mock(ApplicationEx.class, "application");
    context.checking(new Expectations() {

        {
            allowing(myApplication).isUnitTestMode();
            will(returnValue(false));
            allowing(myApplication).getName();
            will(returnValue("IDEA"));
            // some tests leave invokeLater()'s after them
            allowing(myApplication).invokeLater(with(any(Runnable.class)), with(any(ModalityState.class)));
            allowing(myApplication).runReadAction(with(any(Runnable.class)));
            will(new Action() {

                @Override
                public void describeTo(final Description description) {
                    description.appendText("runs runnable");
                }

                @Override
                @Nullable
                public Object invoke(final Invocation invocation) throws Throwable {
                    ((Runnable) invocation.getParameter(0)).run();
                    return null;
                }
            });
        }
    });
    final ExtensionsArea area = Extensions.getRootArea();
    final String epName = PathMacrosCollector.MACRO_FILTER_EXTENSION_POINT_NAME.getName();
    if (!area.hasExtensionPoint(epName)) {
        area.registerExtensionPoint(epName, "com.intellij.openapi.application.PathMacroFilter");
        Disposer.register(myRootDisposable, new Disposable() {

            @Override
            public void dispose() {
                area.unregisterExtensionPoint(epName);
            }
        });
    }
}
Also used : Expectations(org.jmock.Expectations) Disposable(com.intellij.openapi.Disposable) ExtensionsArea(com.intellij.openapi.extensions.ExtensionsArea) JUnit4Mockery(org.jmock.integration.junit4.JUnit4Mockery) Action(org.jmock.api.Action) Description(org.hamcrest.Description) ApplicationEx(com.intellij.openapi.application.ex.ApplicationEx) Invocation(org.jmock.api.Invocation) ModalityState(com.intellij.openapi.application.ModalityState) Before(org.junit.Before)

Example 7 with ExtensionsArea

use of com.intellij.openapi.extensions.ExtensionsArea in project intellij-community by JetBrains.

the class PyCharmEduInitialConfigurator method patchProjectAreaExtensions.

private static void patchProjectAreaExtensions(@NotNull final Project project) {
    Executor debugExecutor = DefaultDebugExecutor.getDebugExecutorInstance();
    unregisterAction(debugExecutor.getId(), ExecutorRegistryImpl.RUNNERS_GROUP);
    unregisterAction(debugExecutor.getContextActionId(), ExecutorRegistryImpl.RUN_CONTEXT_GROUP);
    ExtensionsArea projectArea = Extensions.getArea(project);
    for (SelectInTarget target : Extensions.getExtensions(SelectInTarget.EP_NAME, project)) {
        if (ToolWindowId.FAVORITES_VIEW.equals(target.getToolWindowId()) || ToolWindowId.STRUCTURE_VIEW.equals(target.getToolWindowId())) {
            projectArea.getExtensionPoint(SelectInTarget.EP_NAME).unregisterExtension(target);
        }
    }
    for (AbstractProjectViewPane pane : Extensions.getExtensions(AbstractProjectViewPane.EP_NAME, project)) {
        if (pane.getId().equals(ScopeViewPane.ID)) {
            Disposer.dispose(pane);
            projectArea.getExtensionPoint(AbstractProjectViewPane.EP_NAME).unregisterExtension(pane);
        }
    }
}
Also used : ExtensionsArea(com.intellij.openapi.extensions.ExtensionsArea) DefaultDebugExecutor(com.intellij.execution.executors.DefaultDebugExecutor) Executor(com.intellij.execution.Executor) SelectInTarget(com.intellij.ide.SelectInTarget) AbstractProjectViewPane(com.intellij.ide.projectView.impl.AbstractProjectViewPane)

Example 8 with ExtensionsArea

use of com.intellij.openapi.extensions.ExtensionsArea in project intellij-community by JetBrains.

the class PyCharmEduInitialConfigurator method patchRootAreaExtensions.

private static void patchRootAreaExtensions() {
    ExtensionsArea rootArea = Extensions.getArea(null);
    rootArea.unregisterExtensionPoint("com.intellij.runLineMarkerContributor");
    for (ToolWindowEP ep : Extensions.getExtensions(ToolWindowEP.EP_NAME)) {
        if (ToolWindowId.FAVORITES_VIEW.equals(ep.id) || ToolWindowId.TODO_VIEW.equals(ep.id) || EventLog.LOG_TOOL_WINDOW_ID.equals(ep.id) || ToolWindowId.STRUCTURE_VIEW.equals(ep.id)) {
            rootArea.getExtensionPoint(ToolWindowEP.EP_NAME).unregisterExtension(ep);
        }
    }
    for (DirectoryProjectConfigurator ep : Extensions.getExtensions(DirectoryProjectConfigurator.EP_NAME)) {
        if (ep instanceof PlatformProjectViewOpener) {
            rootArea.getExtensionPoint(DirectoryProjectConfigurator.EP_NAME).unregisterExtension(ep);
        }
    }
    // unregister unrelated tips
    for (TipAndTrickBean tip : Extensions.getExtensions(TipAndTrickBean.EP_NAME)) {
        if (UNRELATED_TIPS.contains(tip.fileName)) {
            rootArea.getExtensionPoint(TipAndTrickBean.EP_NAME).unregisterExtension(tip);
        }
    }
    for (IntentionActionBean ep : Extensions.getExtensions(IntentionManager.EP_INTENTION_ACTIONS)) {
        if ("org.intellij.lang.regexp.intention.CheckRegExpIntentionAction".equals(ep.className)) {
            rootArea.getExtensionPoint(IntentionManager.EP_INTENTION_ACTIONS).unregisterExtension(ep);
        }
    }
    final ExtensionPoint<ProjectAttachProcessor> point = Extensions.getRootArea().getExtensionPoint(ProjectAttachProcessor.EP_NAME);
    for (ProjectAttachProcessor attachProcessor : Extensions.getExtensions(ProjectAttachProcessor.EP_NAME)) {
        point.unregisterExtension(attachProcessor);
    }
}
Also used : ProjectAttachProcessor(com.intellij.projectImport.ProjectAttachProcessor) ExtensionsArea(com.intellij.openapi.extensions.ExtensionsArea) DirectoryProjectConfigurator(com.intellij.platform.DirectoryProjectConfigurator) TipAndTrickBean(com.intellij.ide.util.TipAndTrickBean) IntentionActionBean(com.intellij.codeInsight.intention.IntentionActionBean) PlatformProjectViewOpener(com.intellij.platform.PlatformProjectViewOpener)

Example 9 with ExtensionsArea

use of com.intellij.openapi.extensions.ExtensionsArea in project android by JetBrains.

the class CaptureServiceTest method testUpdate.

public void testUpdate() throws Exception {
    CaptureService service = CaptureService.getInstance(myProject);
    assertNull(service.getCapturesDirectory());
    VirtualFile projectDir = LocalFileSystem.getInstance().findFileByPath(myProject.getBasePath());
    assertNotNull(projectDir);
    VirtualFile captures = createChildDirectory(projectDir, "captures");
    assertTrue(service.getCaptures().isEmpty());
    createChildData(captures, "data.capture");
    service.update();
    assertTrue(service.getCaptures().isEmpty());
    ExtensionsArea area = Extensions.getRootArea();
    Element element = readElement("  <extensions defaultExtensionNs=\"com.android\">\n" + "    <captureType implementation=\"" + MyCaptureType.class.getName() + "\"/>\n  </extensions>");
    area.registerExtension(new DefaultPluginDescriptor(PluginId.getId("com.android")), element.getChild("captureType"));
    MyCaptureType type = CaptureTypeService.getInstance().getType(MyCaptureType.class);
    service.update();
    assertEquals(1, service.getCaptures().size());
    assertEquals(type, service.getCaptures().iterator().next().getType());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ExtensionsArea(com.intellij.openapi.extensions.ExtensionsArea) Element(org.jdom.Element) DefaultPluginDescriptor(com.intellij.openapi.extensions.DefaultPluginDescriptor)

Aggregations

ExtensionsArea (com.intellij.openapi.extensions.ExtensionsArea)9 ExtensionPoint (com.intellij.openapi.extensions.ExtensionPoint)2 Configurable (com.intellij.openapi.options.Configurable)2 ConfigurableEP (com.intellij.openapi.options.ConfigurableEP)2 Project (com.intellij.openapi.project.Project)2 ArrayList (java.util.ArrayList)2 IntentionActionBean (com.intellij.codeInsight.intention.IntentionActionBean)1 Executor (com.intellij.execution.Executor)1 DefaultDebugExecutor (com.intellij.execution.executors.DefaultDebugExecutor)1 SelectInTarget (com.intellij.ide.SelectInTarget)1 AbstractProjectViewPane (com.intellij.ide.projectView.impl.AbstractProjectViewPane)1 TipAndTrickBean (com.intellij.ide.util.TipAndTrickBean)1 MockLocalFileSystem (com.intellij.mock.MockLocalFileSystem)1 Disposable (com.intellij.openapi.Disposable)1 AnAction (com.intellij.openapi.actionSystem.AnAction)1 ModalityState (com.intellij.openapi.application.ModalityState)1 ApplicationEx (com.intellij.openapi.application.ex.ApplicationEx)1 DefaultPluginDescriptor (com.intellij.openapi.extensions.DefaultPluginDescriptor)1 Module (com.intellij.openapi.module.Module)1 ProjectJdkTable (com.intellij.openapi.projectRoots.ProjectJdkTable)1