use of org.eclipse.emf.ecore.util.Diagnostician in project rest-modeling-framework by commercetools.
the class RamlValidationSetup method setupCustom.
/**
* Registers validators.
*/
static Diagnostician setupCustom(List<RamlValidator> customValidators) {
final EValidator.Registry registry = new EValidatorRegistryImpl();
final List<EValidator> eValidators = customValidators.stream().map(ramlValidator -> (EValidator) ramlValidator).collect(Collectors.toList());
registry.put(TypesPackage.eINSTANCE, new TypesValidator());
registry.put(ModulesPackage.eINSTANCE, new ModulesValidator());
registry.put(ResourcesPackage.eINSTANCE, new ResourcesValidator());
registry.put(ResponsesPackage.eINSTANCE, new ResponsesValidator());
final RamlObjectValidator ramlObjectValidator = new RamlObjectValidator();
for (final EPackage ePackage : PACKAGES) {
final CompositeValidator compositeValidator = new CompositeValidator();
compositeValidator.add(ramlObjectValidator);
final EValidator validator = registry.getEValidator(ePackage);
if (validator != null) {
compositeValidator.add(validator);
}
if (eValidators.size() > 0) {
compositeValidator.addAll(eValidators);
}
registry.put(ePackage, compositeValidator);
}
return new Diagnostician(registry);
}
use of org.eclipse.emf.ecore.util.Diagnostician in project rest-modeling-framework by commercetools.
the class RamlValidationSetup method setupCustomOnly.
static Diagnostician setupCustomOnly(List<RamlValidator> customValidators) {
final EValidator.Registry registry = new EValidatorRegistryImpl();
final List<EValidator> eValidators = customValidators.stream().map(ramlValidator -> (EValidator) ramlValidator).collect(Collectors.toList());
for (final EPackage ePackage : PACKAGES) {
final CompositeValidator compositeValidator = new CompositeValidator();
final EValidator validator = registry.getEValidator(ePackage);
if (validator != null) {
compositeValidator.add(validator);
}
if (eValidators.size() > 0) {
compositeValidator.addAll(eValidators);
}
registry.put(ePackage, compositeValidator);
}
return new Diagnostician(registry);
}
use of org.eclipse.emf.ecore.util.Diagnostician in project sirius-components by eclipse-sirius.
the class EMFValidationService method validate.
private List<Object> validate(EditingContext editingContext) {
AdapterFactoryEditingDomain domain = editingContext.getDomain();
Map<Object, Object> options = new HashMap<>();
options.put(Diagnostician.VALIDATE_RECURSIVELY, true);
Diagnostician diagnostician = this.getNewDiagnostician();
// @formatter:off
return domain.getResourceSet().getResources().stream().map(Resource::getContents).flatMap(Collection::stream).map(eObject -> diagnostician.validate(eObject, options)).map(Diagnostic::getChildren).flatMap(Collection::stream).collect(Collectors.toList());
// @formatter:on
}
use of org.eclipse.emf.ecore.util.Diagnostician in project xtext-extras by eclipse.
the class AbstractTypeProviderTest method setUp.
@Before
public void setUp() throws Exception {
EValidator.Registry registry = new EValidatorRegistryImpl(EValidator.Registry.INSTANCE);
registry.put(TypesPackage.eINSTANCE, new EObjectValidator());
diagnostician = new Diagnostician(registry);
}
use of org.eclipse.emf.ecore.util.Diagnostician in project xtext-eclipse by eclipse.
the class AbstractTypeProviderTest method setUp.
@Before
public void setUp() throws Exception {
EValidator.Registry registry = new EValidatorRegistryImpl(EValidator.Registry.INSTANCE);
registry.put(TypesPackage.eINSTANCE, new EObjectValidator());
diagnostician = new Diagnostician(registry);
}
Aggregations