Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Referring to user-defined variables from Xbase expressions
Referring to user-defined variables from Xbase expressions [message #1038150] Wed, 10 April 2013 13:17 Go to next message
Oren Mishali is currently offline Oren MishaliFriend
Messages: 15
Registered: March 2013
Junior Member
Hi all,
In my DSL I use Xbase expressions, and I would like to refer from within the expressions to other variables defined in the DSL. For example:

mydsl {
  condition c1 = false, c2 = true;
  requires c1 && c2;

Note that c1 and c2 are NOT Xbase variables, they are defined using a native grammar. The grammar of the requires clause is defined as follows:

	'requires' expression = XOrExpression ';'

I tried to to somehow modify MyDslScopeProvider but without success -- I still get
"Couldn't resolve reference to JvmIdentifiableElement 'c1'" errors.

Thanks in advance,
Re: Referring to user-defined variables from Xbase expressions [message #1038293 is a reply to message #1038150] Wed, 10 April 2013 17:31 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13316
Registered: July 2009
Senior Member

this is usually done via JvmModelInferrer.
here an example

	expression = XOrExpression

	"var" name=ID

class MyDslJvmModelInferrer extends AbstractModelInferrer {

     * convenience API to build and initialize JVM types and their members.
	@Inject extension JvmTypesBuilder

   	def dispatch void infer(Model element, IJvmDeclaredTypeAcceptor acceptor, boolean isPreIndexingPhase) {
   				for (v : element.vars) {
   					members += v.toField(, v.newTypeRef(Boolean::TYPE))
   				members += element.toMethod("xxxx", element.newTypeRef(Boolean::TYPE)) [
   						body = element.expression

Need professional support for Xtext, Xpand, EMF?
Go to:
Twitter : @chrdietrich
Blog :
Previous Topic:Creating an Outline
Next Topic:Need a hint for dynamic imports
Goto Forum:

Current Time: Thu Jan 23 18:11:50 GMT 2020

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

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

Back to the top