use of org.eclipse.pde.core.plugin.IPluginExtension in project dsl-devkit by dsldevkit.
the class CheckExtensionHelperManager method removeExtensions.
/**
* Removes the extensions. Is called when the catalog still exists (it has not been deleted) and plugin extensions which no longer correspond
* to the model exist. This is the case if the model becomes invalid. Extensions are then removed from the plugin model.
*
* @param catalog
* the catalog
* @param pluginModel
* the plugin model
* @param monitor
* the monitor
* @throws CoreException
* the core exception
*/
public void removeExtensions(final CheckCatalog catalog, final IPluginModelBase pluginModel, final IProgressMonitor monitor) throws CoreException {
QualifiedName name = nameConverter.toQualifiedName(projectUtil.getCatalogQualifiedName(catalog));
for (IPluginExtension extension : findExtensions(pluginModel, name, ExtensionType.ALL)) {
final ExtensionType extensionType = getExtensionType(extension);
getExtensionHelper(extensionType).removeExtensionFromPluginBase(pluginModel, extension, catalog, extensionType);
}
}
use of org.eclipse.pde.core.plugin.IPluginExtension in project dsl-devkit by dsldevkit.
the class CheckExtensionHelperManager method sortAllExtensions.
/**
* Sorts the plug-in extensions alphabetically by extension point ID and then by extension ID (and name in case the IDs are equal or null).
*
* @param pluginModel
* the plugin model
* @param monitor
* the monitor
* @throws CoreException
* the core exception
*/
public void sortAllExtensions(final IPluginModelBase pluginModel, final IProgressMonitor monitor) throws CoreException {
Ordering<IPluginExtension> ordering = Ordering.from((a, b) -> ComparisonChain.start().compare(a.getPoint(), b.getPoint()).compare(a.getId(), b.getId(), Ordering.natural().nullsLast()).compare(a.getName(), b.getName(), Ordering.natural().nullsLast()).result());
List<IPluginExtension> catalogExtensions = Lists.newArrayList(findAllExtensions(pluginModel));
List<IPluginExtension> orderedExtensions = ordering.sortedCopy(catalogExtensions);
if (catalogExtensions.equals(orderedExtensions)) {
return;
}
for (int i = 0; i < orderedExtensions.size(); i++) {
IPluginExtension expected = orderedExtensions.get(i);
IPluginExtension actual = catalogExtensions.get(i);
if (!Objects.equals(actual, expected)) {
// pluginModel.getExtensions().swap(expected, actual);
for (int j = i; j < catalogExtensions.size(); j++) {
pluginModel.getExtensions().remove(catalogExtensions.get(j));
}
for (int j = i; j < orderedExtensions.size(); j++) {
pluginModel.getExtensions().add(orderedExtensions.get(j));
}
break;
}
}
}
Aggregations