简体   繁体   中英

Run EMF Validation of an Ecore model outside of Eclipse

I found nothing how to validate an Ecore model outside of Eclipse. Does someone know how to do this?

Here is the skeleton of some code I've used to validate an EMF model outside of Eclipse:

EValidator.Registry.INSTANCE.put(YourPackage.eINSTANCE, new YourValidator());

BasicDiagnostic diagnostics = new BasicDiagnostic();
boolean valid = true;
for (EObject eo : yourResource.getContents()) {
    Map<Object, Object> context = new HashMap<Object, Object>();
    valid &= Diagnostician.INSTANCE.validate(eo, diagnostics, context);
}

There is more customization you can do, but I hope that helps get you started.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM