Skip to main content



      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 11:56 Go to next message
Eclipse UserFriend
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 18:29 Go to previous messageGo to next message
Eclipse UserFriend
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»"'''
			]
			
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 09:09 Go to previous messageGo to next message
Eclipse UserFriend
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] Wed, 02 July 2014 22:50 Go to previous message
Eclipse UserFriend
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: Thu Jul 17 01:19:45 EDT 2025

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

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

Back to the top