Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » [xtend] Question on "Create Functions"
[xtend] Question on "Create Functions" [message #718382] Wed, 24 August 2011 07:36 Go to next message
Nikolai Busse is currently offline Nikolai BusseFriend
Messages: 15
Registered: August 2011
Junior Member
I follow the Xtend documentation and try to create Objects of (my) model class "FieldMember". But
def create result: new FieldMember() newFieldMember	() {}

leads to a syntax error "Couldn't resolve reference to JvmConstructor 'FieldMember'.". Next try is
def FieldMember create result: new FieldMemberImpl() newFieldMember() {}

which compiles, but, on running the generator workflow, leads to a Runtime error:
ERROR mf.mwe2.launch.runtime.Mwe2Launcher  - Unresolved compilation problem: 
	The constructor FieldMemberImpl() is not visible

which is clear to me, since FieldMemberImpl() is protected, and I see the same message in the java file created out of the xtend file.
So the only way I found to create such an object is to write
def newFieldMember () { EbsLangFactory::eINSTANCE.createFieldMember() }

But what goes wrong with the create functions?

Re: [xtend] Question on "Create Functions" [message #718387 is a reply to message #718382] Wed, 24 August 2011 07:45 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13879
Registered: July 2009
Senior Member
Hi,

what about
def create result: EbsLangFactory::eINSTANCE.createFieldMember() newFieldMember () {}

~Christian


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Wed, 24 August 2011 07:51]

Report message to a moderator

Re: [xtend] Question on "Create Functions" [message #718411 is a reply to message #718387] Wed, 24 August 2011 08:51 Go to previous message
Nikolai Busse is currently offline Nikolai BusseFriend
Messages: 15
Registered: August 2011
Junior Member
Hi Christian,
many thanks again for the quick response. It doesn't look that nice as the example from the documentation but it works.
Anyhow I can't use the create function since this always returns the same object, what is exactly what they are for.
A simple
def newFieldMember() { EbsLangFactory::eINSTANCE.createFieldMember }
does it.
Previous Topic:Creating new EObjects from XtextResource
Next Topic:Adding DSL nature to project in same workspace
Goto Forum:
  


Current Time: Mon Apr 12 17:04:09 GMT 2021

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

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

Back to the top