Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Adding feature during post-processing
Adding feature during post-processing [message #1700180] Tue, 30 June 2015 13:47 Go to next message
Chris Bryan is currently offline Chris BryanFriend
Messages: 12
Registered: June 2015
Junior Member
Hi all,

I am trying to add a feature to my EObject classes during post-processing. The following works to add a String:

		val paramFlatList = EcoreFactory.eINSTANCE.createEAttribute
		paramFlatList.name = "flatList"
		paramFlatList.EType = EcorePackage.eINSTANCE.EString

		clazz.EStructuralFeatures.add(paramFlatList)


Can anyone tell me how to change the type to one of my EObject classes? I have tried:

		paramFlatList.EType = EcoreFactory.eINSTANCE.EPackage.getEClassifier("DeclParamListVirtual")


But this fails with a NPE.

Thanks!
Re: Adding feature during post-processing [message #1700196 is a reply to message #1700180] Tue, 30 June 2015 15:39 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi what excatly do you wanto to achieve

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Adding feature during post-processing [message #1700198 is a reply to message #1700196] Tue, 30 June 2015 15:42 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
And why do you cal geteclassifier

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Adding feature during post-processing [message #1700255 is a reply to message #1700196] Wed, 01 July 2015 09:26 Go to previous messageGo to next message
Chris Bryan is currently offline Chris BryanFriend
Messages: 12
Registered: June 2015
Junior Member
Christian Dietrich wrote on Tue, 30 June 2015 15:39
Hi what excatly do you wanto to achieve


What I want to achieve is a new field in an EObject class. The code I posted produces

String flatList;


What I want is to change the String type to another EObject class (or, less preferably, EObject itself). But I don't know what to set EType to besides EcorePackage.eINSTANCE.EString
Re: Adding feature during post-processing [message #1700264 is a reply to message #1700255] Wed, 01 July 2015 10:49 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
you should search the epackage for your eclass.

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Adding feature during post-processing [message #1700287 is a reply to message #1700264] Wed, 01 July 2015 13:22 Go to previous messageGo to next message
Chris Bryan is currently offline Chris BryanFriend
Messages: 12
Registered: June 2015
Junior Member
Christian Dietrich wrote on Wed, 01 July 2015 10:49
you should search the epackage for your eclass.


This is where I am stuck! I don't see anything in the epackage that ties to my particular model...?
Re: Adding feature during post-processing [message #1700290 is a reply to message #1700287] Wed, 01 July 2015 13:33 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
from your code i do not see where you try to search the package

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Adding feature during post-processing [message #1700292 is a reply to message #1700290] Wed, 01 July 2015 13:36 Go to previous messageGo to next message
Chris Bryan is currently offline Chris BryanFriend
Messages: 12
Registered: June 2015
Junior Member
Christian Dietrich wrote on Wed, 01 July 2015 13:33
from your code i do not see where you try to search the package


I have tried (for instance)
EcorePackage.eINSTANCE.getEClassifier("TestTemplate")


Where TestTemplate is a rule in my grammar, and exists as TestTemplate.java and TestTemplateImpl.java. This returns null...

Thanks for your help.
Re: Adding feature during post-processing [message #1700293 is a reply to message #1700292] Wed, 01 July 2015 13:41 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
No ?!? that is not searching the type in the package you get from xtext
https://christiandietrich.wordpress.com/2011/07/22/customizing-xtext-metamodel-inference-using-xtend2/



Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Adding feature during post-processing [message #1700296 is a reply to message #1700293] Wed, 01 July 2015 14:09 Go to previous message
Chris Bryan is currently offline Chris BryanFriend
Messages: 12
Registered: June 2015
Junior Member
Ah! I see now-- I had read this example many times, but didn't pay enough attention to the beginning Confused
Previous Topic:Xtext 2.9
Next Topic:get path of the active project
Goto Forum:
  


Current Time: Thu Apr 25 19:03:54 GMT 2024

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

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

Back to the top