Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How can I create a variable or static initializer with Xbase means
How can I create a variable or static initializer with Xbase means [message #1391925] Tue, 01 July 2014 15:56 Go to next message
Olaf Bigalk is currently offline Olaf BigalkFriend
Messages: 141
Registered: July 2009
Location: Berlin
Senior Member
I would like to generate a variable with an initial value or alternative a static or non static initializer to initialize the variable.
How can I do this with present Xbase means?
Re: How can I create a variable or static initializer with Xbase means [message #1392108 is a reply to message #1391925] Tue, 01 July 2014 22:29 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13271
Registered: July 2009
Senior Member
on which level? within a method? partial inference of bodies is still not possible afaik,
as a field?

members += entity.toField("entityName", it.newTypeRef("String")) [
				initializer = '''"«entity.name»"'''
			]
			


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How can I create a variable or static initializer with Xbase means [message #1392522 is a reply to message #1392108] Wed, 02 July 2014 13:09 Go to previous messageGo to next message
Jan Rosczak is currently offline Jan RosczakFriend
Messages: 53
Registered: July 2009
Location: Hamburg, Germany
Member
I have a specific usecase for such a desire. Let's say I have a specialized XBlockExpression and inside that XBlockExpression I want to have access to a local variable which has been created automatically.
MySpecialBlock {
   if (specialLocalVariable != null) {
   }
}


Is this possible? Maybe do this in the TypeComputer?

Another idea could be to generate a XVariable instance in the DerivedStateProcessor and attach it to the EObject of my special XBlockExpression so I can access and add that variable to the local scope in the TypeComputer later? Would that be a way forward and how do I correctly access the required JvmType in the DerivedStateProcessor?
Re: How can I create a variable or static initializer with Xbase means [message #1392940 is a reply to message #1392108] Thu, 03 July 2014 02:50 Go to previous message
Olaf Bigalk is currently offline Olaf BigalkFriend
Messages: 141
Registered: July 2009
Location: Berlin
Senior Member
Christian Dietrich wrote on Tue, 01 July 2014 18:29
on which level? within a method? partial inference of bodies is still not possible afaik,
as a field?

members += entity.toField("entityName", it.newTypeRef("String")) [
				initializer = '''"«entity.name»"'''
			]
			

Thank you for that hint. I think that was what I was looking for.
Previous Topic:Generating Enums with Xbase
Next Topic:Resolvig ProxyObjects from importUri Scope
Goto Forum:
  


Current Time: Wed Dec 11 16:12:57 GMT 2019

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

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

Back to the top