Search in sources :

Example 1 with AreaInstance

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

the class ExtensionsComplexTest method testPluginInit.

@Test
public void testPluginInit() throws Exception {
    initExtensionPoints(PLUGIN_NAME, "<extensionPoints>\n" + "  <extensionPoint name=\"extensionPoint\" beanClass=\"com.intellij.openapi.extensions.impl.XMLTestBean\" />\n" + "  <extensionPoint name=\"dependentOne\" beanClass=\"com.intellij.openapi.extensions.impl.DependentObjectOne\" />\n" + "</extensionPoints>", null);
    initExtensions("  <extensions xmlns=\"the.test.plugin\">\n" + "    <extensionPoint>\n" + "      <prop1>321</prop1>\n" + "    </extensionPoint>\n" + "    <dependentOne/>\n" + "  </extensions>", null);
    assertTrue(Extensions.getRootArea().hasExtensionPoint("the.test.plugin.extensionPoint"));
    assertEquals(1, Extensions.getExtensions("the.test.plugin.extensionPoint").length);
    ExtensionPoint<XMLTestBean> ep = Extensions.getRootArea().getExtensionPoint("the.test.plugin.extensionPoint");
    XMLTestBean bean = ep.getExtension();
    assertNotNull(bean);
    assertEquals(321, bean.getProp1());
    assertEquals("the.test.plugin", bean.getPluginId().getIdString());
    DependentObjectOne dependentObjectOne = (DependentObjectOne) Extensions.getRootArea().getExtensionPoint("the.test.plugin.dependentOne").getExtension();
    assertNotNull(dependentObjectOne);
    assertEquals(1, dependentObjectOne.getTestBeans().length);
    AreaInstance areaInstance = new MyAreaInstance();
    Extensions.instantiateArea("area", areaInstance, null);
    initExtensionPoints(PLUGIN_NAME, "<extensionPoints>\n" + "  <extensionPoint name=\"dependentTwo\" beanClass=\"com.intellij.openapi.extensions.impl.DependentObjectTwo\" area=\"area\"/>\n" + "  <extensionPoint name=\"extensionPoint4area\" beanClass=\"com.intellij.openapi.extensions.impl.XMLTestBean\" area=\"area\" />\n" + "</extensionPoints>", areaInstance);
    initExtensions("  <extensions xmlns=\"the.test.plugin\">\n" + "    <extensionPoint4area area=\"area\"/>\n" + "    <dependentTwo area=\"area\"/>\n" + "  </extensions>", areaInstance);
    ExtensionPoint extensionPoint = Extensions.getArea(areaInstance).getExtensionPoint("the.test.plugin.extensionPoint4area");
    assertNotNull(extensionPoint);
    assertSame(areaInstance, extensionPoint.getArea());
    assertNotNull(extensionPoint.getExtension());
    DependentObjectTwo dependentObjectTwo = (DependentObjectTwo) Extensions.getArea(areaInstance).getExtensionPoint("the.test.plugin.dependentTwo").getExtension();
    assertNotNull(dependentObjectTwo);
    assertSame(dependentObjectOne, dependentObjectTwo.getOne());
}
Also used : ExtensionPoint(com.intellij.openapi.extensions.ExtensionPoint) AreaInstance(com.intellij.openapi.extensions.AreaInstance) Test(org.junit.Test)

Aggregations

AreaInstance (com.intellij.openapi.extensions.AreaInstance)1 ExtensionPoint (com.intellij.openapi.extensions.ExtensionPoint)1 Test (org.junit.Test)1