|How to manufacture model elements [message #1047858]
||Tue, 23 April 2013 15:01
| Chris Ainsley
Registered: March 2010
I have added an eOperation to my .ecore model that will return a list of elements, some of which are scanned and manufactured from the file system.
I also added an implementation for this method in a custom model implementation class and am using some naive model generation code as follows:
Collection collection = AttributesFactory.eINSTANCE.createCollection();
I really didn't expect it to work at all, but it does kind of work, albeit naively and only in the case that there are zero validation problems with the generated model item (Collection).
Now the problem is that when there is a problem validating the manufactured collection the following exception is thrown (as I really expected).
java.lang.IllegalArgumentException: You can only add issues for EObjects contained in the currently validated resource 'platform:/resource/TestProj/attributetest/test.attributes'. But the given EObject was contained in 'null'
Now, obviously, creating an EObject is not just as simple as creating an object then setting the values. I also need to set at minimum some kind of eResource and possibly some other fields.
In this example, the created Collection object corresponds to a folder in the workspace. I'd like to be able to create this Collection and be able to show a validation problem without XText crashing.
How can this be achieved?
Powered by FUDForum
. Page generated in 0.16144 seconds