Search in sources :

Example 21 with IPluginExtension

use of org.eclipse.pde.core.plugin.IPluginExtension in project dsl-devkit by dsldevkit.

the class CheckContextsExtensionTest method testIsExtensionUpdateRequiredTrue.

/**
 * Test if isExtensionUpdateRequired is true, if the file path attribute is not as expected.
 *
 * @throws CoreException
 *           the core exception
 */
@Test
public void testIsExtensionUpdateRequiredTrue() throws CoreException {
    IPluginExtension extension = createErroneousExtension();
    Iterable<IPluginElement> elements = Iterables.filter(Lists.newArrayList(extension.getChildren()), IPluginElement.class);
    assertTrue("Extension update is required", contextsUtil.isExtensionUpdateRequired(catalog, extension, elements));
}
Also used : IPluginExtension(org.eclipse.pde.core.plugin.IPluginExtension) IPluginElement(org.eclipse.pde.core.plugin.IPluginElement) Test(org.junit.Test)

Example 22 with IPluginExtension

use of org.eclipse.pde.core.plugin.IPluginExtension in project dsl-devkit by dsldevkit.

the class CheckTocExtensionTest method testIsExtensionUpdateRequiredTrue.

/**
 * Tests if isExtensionUpdateRequired returns true if only an erroneous extension exists for the check catalog.
 *
 * @throws CoreException
 *           the core exception
 */
@Test
public void testIsExtensionUpdateRequiredTrue() throws CoreException {
    IPluginExtension extension = createErroneousTocExtension();
    Iterable<IPluginElement> elements = Iterables.filter(Lists.newArrayList(extension.getChildren()), IPluginElement.class);
    assertTrue("Toc extension update is required", tocUtil.isExtensionUpdateRequired(catalog, extension, elements));
}
Also used : IPluginExtension(org.eclipse.pde.core.plugin.IPluginExtension) IPluginElement(org.eclipse.pde.core.plugin.IPluginElement) Test(org.junit.Test)

Example 23 with IPluginExtension

use of org.eclipse.pde.core.plugin.IPluginExtension in project dsl-devkit by dsldevkit.

the class AbstractCheckExtensionHelper method addExtensionToPluginBase.

@Override
public IPluginExtension addExtensionToPluginBase(final IPluginModelBase base, final CheckCatalog catalog, final ExtensionType type, final String extensionId) throws CoreException {
    if (isExtensionEnabled(base, catalog, type, extensionId)) {
        IPluginExtension newExtension = createExtension(catalog, extensionId, base);
        base.getPluginBase().add(newExtension);
        return newExtension;
    }
    return null;
}
Also used : IPluginExtension(org.eclipse.pde.core.plugin.IPluginExtension)

Example 24 with IPluginExtension

use of org.eclipse.pde.core.plugin.IPluginExtension in project dsl-devkit by dsldevkit.

the class CheckExtensionHelperManager method updateExtensions.

/**
 * Update check catalog extensions if necessary.
 *
 * @param catalog
 *          the catalog
 * @param pluginModel
 *          the plugin model
 * @param monitor
 *          the monitor
 * @throws CoreException
 *           the core exception
 */
public void updateExtensions(final CheckCatalog catalog, final IPluginModelBase pluginModel, final IProgressMonitor monitor) throws CoreException {
    QualifiedName catalogName = nameProvider.apply(catalog);
    Collection<IPluginExtension> catalogExtensions = findExtensions(pluginModel, catalogName, ExtensionType.ALL);
    // Update extensions as appropriate
    for (IPluginExtension extension : catalogExtensions) {
        if (!hasGrammar(catalog)) {
            // no extensions for Catalogs without valid grammar
            pluginModel.getPluginBase().remove(extension);
            // nothing more to do if no grammar is available
            continue;
        } else {
            for (ICheckExtensionHelper helper : getExtensionHelpers()) {
                // TODO getExtensionHelper using extension.getPoint() would make this more efficient
                helper.updateExtension(catalog, extension);
            }
        }
    }
}
Also used : IPluginExtension(org.eclipse.pde.core.plugin.IPluginExtension) QualifiedName(org.eclipse.xtext.naming.QualifiedName)

Example 25 with IPluginExtension

use of org.eclipse.pde.core.plugin.IPluginExtension in project dsl-devkit by dsldevkit.

the class CheckExtensionHelperManager method addExtensions.

/**
 * Add check catalog extensions if not already existing.
 *
 * @param catalog
 *          the catalog
 * @param pluginModel
 *          the plugin model
 * @param monitor
 *          the monitor
 * @throws CoreException
 *           the core exception
 */
public void addExtensions(final CheckCatalog catalog, final IPluginModelBase pluginModel, final IProgressMonitor monitor) throws CoreException {
    QualifiedName catalogName = nameProvider.apply(catalog);
    Collection<IPluginExtension> catalogExtensions = findExtensions(pluginModel, catalogName, ExtensionType.ALL);
    Iterable<ExtensionType> registeredExtensionTypes = findExtensionTypes(catalogExtensions);
    if (hasGrammar(catalog)) {
        for (ExtensionType type : ExtensionType.values()) {
            ICheckExtensionHelper helper = getExtensionHelper(type);
            if (helper == null) {
                continue;
            }
            if (!Iterables.contains(registeredExtensionTypes, type)) {
                helper.addExtensionToPluginBase(pluginModel, catalog, type, getExtensionId(nameProvider.apply(catalog), type));
            }
        }
    }
}
Also used : IPluginExtension(org.eclipse.pde.core.plugin.IPluginExtension) QualifiedName(org.eclipse.xtext.naming.QualifiedName)

Aggregations

IPluginExtension (org.eclipse.pde.core.plugin.IPluginExtension)27 IPluginElement (org.eclipse.pde.core.plugin.IPluginElement)19 Test (org.junit.Test)12 CheckCatalog (com.avaloq.tools.ddk.check.check.CheckCatalog)4 IPluginObject (org.eclipse.pde.core.plugin.IPluginObject)3 QualifiedName (org.eclipse.xtext.naming.QualifiedName)3 XIssueExpression (com.avaloq.tools.ddk.check.check.XIssueExpression)1