Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Initializing field in generated class
Initializing field in generated class [message #890944] Sat, 23 June 2012 14:25 Go to next message
Andreas Beckers is currently offline Andreas BeckersFriend
Messages: 8
Registered: November 2009
Junior Member
Hi,
Bases on the domain model example I want to write a little language. I have some problems to figurwe out, how to work with xtend2 to generate my resulting classes.

I found out, that
members += table.toField('abc', table.newTypeRef('int')) [
^static = true
]

gives me
private static int abc;

but I would like to get
private static int abc = 42;

I couldn't figure it out. Also I didn't find how to create a static initializer.

static {
abc = 42;
}

Is there any tutorial for an extended use of this way to generate java classes?
Any help welcome.
Andreas
Re: Initializing field in generated class [message #890948 is a reply to message #890944] Sat, 23 June 2012 14:44 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
e.g.

val field = f.toField(f.name, f.type) [
							^static = true
							val Procedure1<ITreeAppendable> b = [
								 append('''123''')
							]
							initializer = b
						]


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Initializing field in generated class [message #890970 is a reply to message #890948] Sat, 23 June 2012 16:03 Go to previous message
Andreas Beckers is currently offline Andreas BeckersFriend
Messages: 8
Registered: November 2009
Junior Member
Works, thanks.
Previous Topic:How to access a cross reference from a content-assist-provider?
Next Topic:preprocessor before parsing needed
Goto Forum:
  


Current Time: Fri Apr 26 15:51:01 GMT 2024

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

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

Back to the top