| Summary: | NPE in EvlValidator.validate() | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Product: | [Modeling] Epsilon | Reporter: | Mirko Seifert <mirko.seifert> | ||||||||||
| Component: | Core | Assignee: | Dimitris Kolovos <dkolovos> | ||||||||||
| Status: | ASSIGNED --- | QA Contact: | |||||||||||
| Severity: | normal | ||||||||||||
| Priority: | P3 | ||||||||||||
| Version: | unspecified | ||||||||||||
| Target Milestone: | --- | ||||||||||||
| Hardware: | PC | ||||||||||||
| OS: | Windows 7 | ||||||||||||
| Whiteboard: | |||||||||||||
| Attachments: |
|
||||||||||||
|
Description
Mirko Seifert
I believe that this NPE can be thrown only if "diagnostics" in public boolean validate(EClass eClass, EObject eObject,DiagnosticChain diagnostics, Map<Object, Object> context) is null. Are you perhaps calling this method from within the EMFText integration code with a null parameter? I call: org.eclipse.emf.common.util.Diagnostic diagnostics = org.eclipse.emf.ecore.util.Diagnostician.INSTANCE.validate(root); (root is my root EObject). So 'diagnostics' seems to be set/created by EMF itself. Is my call incorrect? Hi Mirko. Have you perhaps resolved this? If not, would it be possible to attach a minimal test case that I can use to reproduce this and investigate further? No, I did not resolve this. I'll attach a JUnit Plug-in test, which reproduces the bug. Created attachment 174784 [details]
Plug-in project containing a test case
Thanks Mirko. I'll investigate and get back to you. Apologies for the late reply. I've modified the testNPE method slightly (look for lines with "dkolovos") and now the test passes:
public void testNPE() throws URISyntaxException {
// create dynamic EPackage
String namespaceURI = "http://www.epsilon.org/test";
EPackage ePackage = EcoreFactory.eINSTANCE.createEPackage();
ePackage.setName("TestPackage");
ePackage.setNsURI(namespaceURI);
EClass eClass = EcoreFactory.eINSTANCE.createEClass();
eClass.setName("A");
ePackage.getEClassifiers().add(eClass);
EAttribute nameAttribute = EcoreFactory.eINSTANCE.createEAttribute();
nameAttribute.setName("name");
nameAttribute.setEType(EcorePackage.eINSTANCE.getEString());
eClass.getEStructuralFeatures().add(nameAttribute); // dkolovos: Added name attribute to the structural features of the class
EPackage.Registry.INSTANCE.put(ePackage.getNsURI(), ePackage); // dkolovos: ++ Register EPackage
// register EVL file
String modelName = EvlValidator.DEFAULT_MODEL_NAME;
// TODO I'm not sure whether the URI is correct
// dkolovos: It was not :) It should be an absolute URI like the following
EValidator evlValidator = new EvlValidator(new URI("platform:/plugin/org.epsilon.evl.test/constraints/constraints.evl"), modelName, namespaceURI);
EValidator.Registry.INSTANCE.put(ePackage, evlValidator);
// create dynamic model instance
EObject root = ePackage.getEFactoryInstance().create(eClass);
Resource resource = new ResourceSetImpl().createResource(org.eclipse.emf.common.util.URI.createURI("temp.xmi"));
resource.getContents().add(root);
// now call validation (this throws the NPE)
org.eclipse.emf.common.util.Diagnostic diagnostics =
org.eclipse.emf.ecore.util.Diagnostician.INSTANCE.validate(root);
// TODO check whether the result of the validation is correct
}
Please let us know if you come across any other issues while integrating EMFText with EVL.
Hi Dimitrios, the test case does succeed now, but my problem remains. I experiences the NPE when using EVL from plug-ins generated by EMFText. The modifications you've made to the test case are most probably causing my NPE. The generated plug-ins run within Eclipse. Therefore the EPackage is registered. I did not check this, but since EMFText used the generated EMF code, the package is registered whenever the first metaclass is instantiated. This is of course way before EVL comes into play. Also my metamodel has the element that are used by the EVL constraints. I only forgot to do this correctly in the test case. This leaves the wrong URI when creating the EvlValidator. However, I do register my constraint via extension point. This creation is therefore handled by Epsilon. All in all, I think the test case produced the same symptoms, but the underlying problem is a different one in my case. I think the easiest way to figure out what's going on it to attach the generated plug-ins to this report, so you can have a look at it. The plug-ins compile without having EMFText installed. After importing them you should be able to use them. (In reply to comment #8) > Hi Dimitrios, > > The modifications you've > made to the test case are most probably causing my NPE. I meant: "are most probably NOT causing my NPE." Created attachment 178844 [details]
Plug-ins to reproduce the NPE
To reproduce the problem start a new Eclipse instance, create a .rules files with the following content: shapes circ "a" rect "b" circ "c" When saving the file, the NPE gets thrown. I tried again with the current version from the interim update site (0.8.9.201010171057) and the NPE exception is gone. However, problems remain with the quick fixes provided by EVL. I've already made the suggested changes to EMFText, but I still face some problems: 1. The error markers for constraints are not shown right after starting up a fresh Eclipe when the model files is already open. When I close the file and open it again, the errors are shown. 2. When selecting a problem in the problems view an exception is thown by the GmfMarkerResolver. I'll attach a stack trace. 3. When selecting "Quick Fix" on one of the problem markers, only the "Ignore" fix is shown in the list, but not the fix defined in the .evl file. I'll attach a new version of the example plug-ins where the code is generated with the current trunk version of EMFText. Created attachment 181096 [details]
New set of test plug-ins
Created attachment 181097 [details]
Stack trace for NPE in GmfMarkerResolver
|