Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Add custom field while inferring
Add custom field while inferring [message #1450308] Wed, 22 October 2014 10:00 Go to next message
Tobias Wink is currently offline Tobias WinkFriend
Messages: 20
Registered: September 2014
Junior Member
Hi,

I'm back with another problem. Maybe I'm dumb, but I'm not possible to create a field that is not part of my DSL-file.

I want to generate a default primary key attribute if no primary key is defined in my DSL-file. To generate this default primary key I just called the toField-Method of JvmTypesBuilder like with the normal fields.

My Xtend-Code Snippet is (element is an AbstractElement a ):
val identity = toField("identity", getTypeForName("FQN of the appropriate class", element))


While generating the following error occurs:
ERROR org.eclipse.xtext.xbase.jvmmodel.JvmTypesBuilder - The source element must be part of the source tree.
java.lang.IllegalArgumentException: The source element must be part of the source tree.
at org.eclipse.xtext.xbase.jvmmodel.JvmTypesBuilder.isValidSource(JvmTypesBuilder.java:635)
at org.eclipse.xtext.xbase.jvmmodel.JvmTypesBuilder.associate(JvmTypesBuilder.java:620)
at org.eclipse.xtext.xbase.jvmmodel.JvmTypesBuilder.toField(JvmTypesBuilder.java:567)
at org.eclipse.xtext.xbase.jvmmodel.JvmTypesBuilder.toField(JvmTypesBuilder.java:552)

In the generated Java-Class everything looks right. But the Execption is irritating me. What I'm doing wrong?

PS: I'm using Xtext 2.7.2
Re: Add custom field while inferring [message #1450334 is a reply to message #1450308] Wed, 22 October 2014 10:40 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

as source you can take any eclass in your model e.g. the Entity or whatever it is in your case.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Add custom field while inferring [message #1450364 is a reply to message #1450334] Wed, 22 October 2014 11:12 Go to previous message
Tobias Wink is currently offline Tobias WinkFriend
Messages: 20
Registered: September 2014
Junior Member
Thanks. The Exception disappears by using my entity-Element as source
Previous Topic:How ImportURI is used in Xtext
Next Topic:CrossRef Serialization of updated models
Goto Forum:
  


Current Time: Thu Apr 25 14:53:46 GMT 2024

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

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

Back to the top