use of com.avaloq.tools.ddk.check.check.CheckCatalog in project dsl-devkit by dsldevkit.
the class CheckExtensionGenerator method changePluginXmlFile.
/**
* Add an extension to the <code>plugin.xml</code> file.
*
* @param context
* build context
* @param delta
* resource delta
* @param monitor
* progress monitor
* @throws CoreException
* the core exception
*/
public void changePluginXmlFile(final IBuildContext context, final Delta delta, final IProgressMonitor monitor) throws CoreException {
URI uri = delta.getUri();
CheckCatalog catalog = projectHelper.getCatalog(context, uri);
if (catalog == null) {
// $NON-NLS-1$
throw new CoreException(new Status(IStatus.ERROR, Activator.getPluginId(), IStatus.ERROR, "No Catalog found", null));
}
IFile file = getPluginFile(uri);
if (!validPluginFile(file)) {
createNewFile(catalog, file, monitor);
} else {
if (!catalogValidates(catalog)) {
removeExtensions(file, catalog, monitor);
} else {
updateExtensions(file, catalog, monitor);
// TODO improve by only updating the manifest if the validator extension has changed..
}
}
mergeManifest(catalog, monitor);
}
use of com.avaloq.tools.ddk.check.check.CheckCatalog in project dsl-devkit by dsldevkit.
the class CheckMarkerHelpExtensionTest method testMarkerTypeUpdate.
/**
* Tests if the marker type attribute is updated if the trigger kind changes for a check.
*
* @throws Exception
* the exception
*/
@Test
public void testMarkerTypeUpdate() throws Exception {
IPluginExtension extension = createMarkerHelpExtension(parser.parse(CATALOG_WITH_FIRST_CHECK_LIVE));
assertEquals("Before update: Markertype is fast.", MARKERTYPE_FAST, ((IPluginElement) extension.getChildren()[0]).getAttribute(CheckMarkerHelpExtensionHelper.MARKERTYPE_ATTRIBUTE_TAG).getValue());
CheckCatalog updateMarkertype = parser.parse(CATALOG_WITH_FIRST_CHECK_ONDEMAND);
markerUtil.updateExtension(updateMarkertype, extension);
assertEquals("After update: Markertype is expensive.", MARKERTYPE_EXPENSIVE, ((IPluginElement) extension.getChildren()[0]).getAttribute(CheckMarkerHelpExtensionHelper.MARKERTYPE_ATTRIBUTE_TAG).getValue());
}
use of com.avaloq.tools.ddk.check.check.CheckCatalog in project dsl-devkit by dsldevkit.
the class CheckMarkerHelpExtensionTest method testAddElement.
/**
* Tests, if the marker help extension is updated correctly, i.e. add marker help elements for new checks
* and delete the elements of removed checks.
*
* @throws Exception
* the exception
*/
@Test
public void testAddElement() throws Exception {
final CheckCatalog catalogWithOneCheck = parser.parse(CATALOG_WITH_FIRST_CHECK_LIVE);
IPluginExtension extension = createMarkerHelpExtension(catalogWithOneCheck);
assertEquals("Original catalog has one marker help extension", 1, extension.getChildCount());
CheckCatalog catalogWithTwoChecks = parser.parse(CATALOG_WITH_TWO_CHECKS);
markerUtil.updateExtension(catalogWithTwoChecks, extension);
Set<String> contextIds = Sets.newHashSet();
// Test if the marker help element for the old Check has been removed
for (IPluginObject element : extension.getChildren()) {
contextIds.add(((IPluginElement) element).getAttribute(CheckMarkerHelpExtensionHelper.CONTEXT_ID_ATTRIBUTE_TAG).getValue());
}
assertEquals("The extension has two elements", 2, extension.getChildCount());
assertTrue("Both checks are elements of the extension ", contextIds.containsAll(Sets.newHashSet(FIRSTCHECK_CONTEXID, SECONDCHECK_CONTEXTID)));
}
use of com.avaloq.tools.ddk.check.check.CheckCatalog in project dsl-devkit by dsldevkit.
the class CheckMarkerHelpExtensionTest method testCheckHasTwoIssueCodes.
/**
* Tests if a marker help element is added if an additional issueCode is added to an existing check.
*
* @throws Exception
* the exception
*/
@Test
public void testCheckHasTwoIssueCodes() throws Exception {
IPluginExtension extension = createMarkerHelpExtension(parser.parse(CATALOG_WITH_FIRST_CHECK_LIVE));
CheckCatalog twoIssueCodes = parser.parse(CATALOG_CHECK_HAS_TWO_ISSUECODES);
markerUtil.updateExtension(twoIssueCodes, extension);
List<String> issueCodesOfCheck = Lists.newArrayList();
for (final XIssueExpression i : generatorExtension.issues(twoIssueCodes.getChecks().get(0))) {
issueCodesOfCheck.add(CheckGeneratorExtensions.issueCodeValue(twoIssueCodes.getChecks().get(0), CheckGeneratorExtensions.issueCode(i)));
}
List<String> issueCodesInExtension = Lists.newArrayList();
for (IPluginObject obj : extension.getChildren()) {
for (IPluginObject element : ((IPluginElement) obj).getChildren()) {
issueCodesInExtension.add(((IPluginElement) element).getAttribute(CheckMarkerHelpExtensionHelper.ATTRIBUTE_VALUE_TAG).getValue());
}
}
assertTrue("A marker help element for both issueCodes has been created.", Iterables.elementsEqual(issueCodesInExtension, issueCodesOfCheck));
assertEquals("extension has two marker help elements", 2, issueCodesInExtension.size());
}
use of com.avaloq.tools.ddk.check.check.CheckCatalog in project dsl-devkit by dsldevkit.
the class CheckOutlineTreeProvider method internalCreateChildren.
@Override
protected void internalCreateChildren(final DocumentRootNode parentNode, final EObject modelElement) {
CheckCatalog catalog = (CheckCatalog) modelElement;
if (catalog.getPackageName() != null) {
getOutlineNodeFactory().createEStructuralFeatureNode(parentNode, catalog, CheckPackage.Literals.CHECK_CATALOG__PACKAGE_NAME, ImageDescriptor.createFromImage(checkImages.forPackage()), catalog.getPackageName(), true);
}
if (catalog.getImports() != null && !catalog.getImports().getImportDeclarations().isEmpty()) {
EStructuralFeatureNode importNode = getOutlineNodeFactory().createEStructuralFeatureNode(parentNode, catalog, CheckPackage.Literals.CHECK_CATALOG__IMPORTS, ImageDescriptor.createFromImage(checkImages.forImportContainer()), "Import declarations", false);
for (final org.eclipse.xtext.xtype.XImportDeclaration imported : catalog.getImports().getImportDeclarations()) {
createNode(importNode, imported);
}
}
EObjectNode catalogNode = createNode(parentNode, catalog);
for (final Category category : catalog.getCategories()) {
createNode(catalogNode, category);
}
for (final Check check : catalog.getChecks()) {
createNode(catalogNode, check);
}
}
Aggregations