Search in sources :

Example 1 with IValidator

use of org.bndtools.api.IValidator in project bndtools by bndtools.

the class MarkerSupport method validate.

void validate(Project model) throws Exception {
    List<IValidator> validators = loadValidators();
    if (validators != null) {
        for (IValidator v : validators) {
            try {
                if (v instanceof IProjectValidator) {
                    ((IProjectValidator) v).validateProject(model);
                } else {
                    for (Builder builder : model.getSubBuilders()) {
                        IStatus status = v.validate(builder);
                        report(builder, status);
                        model.getInfo(builder);
                    }
                }
            } catch (Exception e) {
                logger.logError("Validator error", e);
            }
        }
    }
}
Also used : IProjectValidator(org.bndtools.api.IProjectValidator) IStatus(org.eclipse.core.runtime.IStatus) IValidator(org.bndtools.api.IValidator) Builder(aQute.bnd.osgi.Builder) CoreException(org.eclipse.core.runtime.CoreException)

Example 2 with IValidator

use of org.bndtools.api.IValidator in project bndtools by bndtools.

the class MarkerSupport method loadValidators.

static List<IValidator> loadValidators() {
    List<IValidator> validators = null;
    IConfigurationElement[] validatorElems = Platform.getExtensionRegistry().getConfigurationElementsFor(CORE_PLUGIN_ID, "validators");
    if (validatorElems != null && validatorElems.length > 0) {
        validators = new ArrayList<IValidator>(validatorElems.length);
        for (IConfigurationElement elem : validatorElems) {
            try {
                validators.add((IValidator) elem.createExecutableExtension("class"));
            } catch (Exception e) {
                logger.logError("Unable to instantiate validator: " + elem.getAttribute("name"), e);
            }
        }
    }
    return validators;
}
Also used : IValidator(org.bndtools.api.IValidator) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) CoreException(org.eclipse.core.runtime.CoreException)

Aggregations

IValidator (org.bndtools.api.IValidator)2 CoreException (org.eclipse.core.runtime.CoreException)2 Builder (aQute.bnd.osgi.Builder)1 IProjectValidator (org.bndtools.api.IProjectValidator)1 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)1 IStatus (org.eclipse.core.runtime.IStatus)1