Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Initializing field in generated class
Initializing field in generated class [message #890944] Sat, 23 June 2012 10:25 Go to next message
Eclipse UserFriend
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 10:44 Go to previous messageGo to next message
Eclipse UserFriend
e.g.

val field = f.toField(f.name, f.type) [
							^static = true
							val Procedure1<ITreeAppendable> b = [
								 append('''123''')
							]
							initializer = b
						]
Re: Initializing field in generated class [message #890970 is a reply to message #890948] Sat, 23 June 2012 12:03 Go to previous message
Eclipse UserFriend
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: Wed Jul 23 13:20:07 EDT 2025

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

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

Back to the top