Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » XText 2.3.0M6 problem with setInitializer(setInitializer does not work in 2.3.0M6?)
XText 2.3.0M6 problem with setInitializer [message #872824] Wed, 16 May 2012 22:28 Go to next message
Mark Utting is currently offline Mark UttingFriend
Messages: 9
Registered: August 2011
Junior Member
I am trying to upgrade from XText 2.2.1 to 2.3.0M6 (2.3.0.v201205081025), but having trouble with the new setBody and setInitializer methods.

For setBody, I can usually just wrap an 'append(...)' around the body and it works okay, but setInitializer is more recalcitrant.

For example, in the following code:

val atoms = new ArrayList<String>()
...
// Generate array of orderby integer values
members += table.orderby.toField("ORDERBY", addArrayTypeDimension(intType)) [
^static = true
^final = true
//was: initializer = ['''{ «atoms.join(", ")», ORDER_END }''']
initializer = [append('''{ «atoms.join(", ")», ORDER_END }''')]
]

the initializer=... line gives the error:

Incompatible types. Expected org.eclipse.xtext.xbase.XExpression but was (null)=>org.eclipse.xtext.xbase.compiler.output.ITreeAppendable
(even though hovering over 'initializer' says that it is using the void setInitializer(JvmField field, Procedure1<ITreeAppendable> strategy) version of setInitializer.)

Can anyone tell me how to fix this?

Is there any documentation about the changes from 2.2.1 to 2.3?

Thanks
Mark
Re: XText 2.3.0M6 problem with setInitializer [message #873095 is a reply to message #872824] Thu, 17 May 2012 13:42 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

i guess the type inferrer is still not that good so what about giving it some hints

val field = f.toField(f.name, f.type)
						[
							val (ITreeAppendable) => void init = [append('''''')] 
							initializer = init
						]


Of course a bugzilla for a better inferrer in this case is welcome i guess.

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: XText 2.3.0M6 problem with setInitializer [message #873997 is a reply to message #872824] Sat, 19 May 2012 18:08 Go to previous message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1823
Registered: July 2009
Senior Member
Please file a bugzilla.

Sven

Am 5/17/12 12:28 AM, schrieb Mark Utting:
> I am trying to upgrade from XText 2.2.1 to 2.3.0M6
> (2.3.0.v201205081025), but having trouble with the new setBody and
> setInitializer methods.
> For setBody, I can usually just wrap an 'append(...)' around the body
> and it works okay, but setInitializer is more recalcitrant.
>
> For example, in the following code:
>
> val atoms = new ArrayList<String>()
> ...
> // Generate array of orderby integer values
> members += table.orderby.toField("ORDERBY",
> addArrayTypeDimension(intType)) [
> ^static = true
> ^final = true
> //was: initializer = ['''{ «atoms.join(", ")», ORDER_END }''']
> initializer = [append('''{ «atoms.join(", ")», ORDER_END }''')]
> ]
>
> the initializer=... line gives the error:
>
> Incompatible types. Expected org.eclipse.xtext.xbase.XExpression but was
> (null)=>org.eclipse.xtext.xbase.compiler.output.ITreeAppendable
> (even though hovering over 'initializer' says that it is using the void
> setInitializer(JvmField field, Procedure1<ITreeAppendable> strategy)
> version of setInitializer.)
>
> Can anyone tell me how to fix this?
>
> Is there any documentation about the changes from 2.2.1 to 2.3?
>
> Thanks
> Mark
>


--
Need professional support for Xtext or other Eclipse Modeling technologies?
Go to: http://xtext.itemis.com
Twitter : @svenefftinge
Blog : http://blog.efftinge.de
Previous Topic:Lookahead value of xtext grammar
Next Topic:higher-level access to model
Goto Forum:
  


Current Time: Fri Apr 19 21:30:54 GMT 2024

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

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

Back to the top