在Eclipse之外运行EMore验证Ecore模型

Dr.*_*rer 6 eclipse validation eclipse-emf eclipse-emf-ecore

我没有发现如何验证Eclipse之外的Ecore模型.有人知道怎么做吗?

Chr*_*isH 4

以下是我用来在 Eclipse 之外验证 EMF 模型的一些代码的框架:

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);
}
Run Code Online (Sandbox Code Playgroud)

您可以进行更多自定义操作,但我希望这可以帮助您入门。