Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How to manufacture model elements
How to manufacture model elements [message #1047858] Tue, 23 April 2013 19:01
Chris Ainsley is currently offline Chris AinsleyFriend
Messages: 77
Registered: March 2010
Location: UK

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'
	at org.eclipse.xtext.validation.AbstractDeclarativeValidator.checkIsFromCurrentlyCheckedResource(
	at org.eclipse.xtext.validation.AbstractDeclarativeValidator.acceptError(
	at org.eclipse.xtext.validation.AbstractDeclarativeValidator.error(
	at org.eclipse.xtext.validation.AbstractDeclarativeValidator.error(
	at org.eclipse.xtext.validation.AbstractDeclarativeValidator.error(

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?
Previous Topic:unique name validation in project, not the whole workspace
Next Topic:variable should visible to only in present function.
Goto Forum:

Current Time: Sun Feb 23 12:20:07 GMT 2020

Powered by FUDForum. Page generated in 0.04622 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top