Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Migrating Xbase-using language to Xtext 2.4
Migrating Xbase-using language to Xtext 2.4 [message #1061160] Thu, 30 May 2013 10:00 Go to next message
Zoltan Ujhelyi is currently offline Zoltan UjhelyiFriend
Messages: 392
Registered: July 2015
Senior Member
Hi,

I am working now on porting an Xtext-based language to the new, 2.4 version, and we have an issue.

Our language defines a set of constraints in a block, where a special constraint is represented by an Xbase expression. This constraint block is a scope that might define new variables, that are usable inside the check expressions.

In Xtext 2.3 we used an extended XbaseScopeProvider, where the createLocalVarScope method was updated to handle these new variable definitions, and additionally used a Declarative Scope Provider for the other sections of the grammar, as described in this forum earlier (http://www.eclipse.org/forums/index.php/mv/msg/219841/699521/#msg_699521).

However, this solution does not work as expected in 2.4. After some experiments I think I have managed to extend that solution to support three scope providers without circles, but the createLocalVarScope method was not called when I expected it.



I have also tried to figure out how to extend the new XbaseBatchScopeProvider class, and found the related IFeatureScopeSession and FeatureScopes classes. After some debugging, I found that if I could introduce a special IFeatureScopeSession for the blocks, I could introduce the new variables as before, but I couldn't find the place where to initialize such scope sessions.

My question is whether you could help me by pointing out where/how can I initialize a new scope that is also visible from check expressions inside?

Thanks for the help,
Zoltán
Re: Migrating Xbase-using language to Xtext 2.4 [message #1061562 is a reply to message #1061160] Sun, 02 June 2013 23:37 Go to previous messageGo to next message
Zoltan Ujhelyi is currently offline Zoltan UjhelyiFriend
Messages: 392
Registered: July 2015
Senior Member
Hi,

I tried to solve the issue stated before, and have compared Scoping setup of our language to other Xbase-based languages (e.g. Xtend), and found out, that they are registered similarly, and the same entry points are called during execution. Basically, in each case either the old XbaseScopeProvider was called (e.g. in case of content assist), but in most cases (e.g. during linking) the new XbaseBatchScopeProvider is used; and in both cases they delegate non-Xbase calls to a Declarative Scope Provider instance.

However, in all cases I have found, that neither of these Scope Providers are called to resolve locally defined variables. As these variables are resolved correctly in case of Xtend (parameters of a method are really similar to my needs), these references are resolved somewhere else.

Could you help me by giving a hint how are parameter references resolved in Xtend (or in case other Xbase languages)? What do I need to customize additionally?

Thanks,
Zoltán
Re: Migrating Xbase-using language to Xtext 2.4 [message #1062058 is a reply to message #1061562] Wed, 05 June 2013 15:20 Go to previous messageGo to next message
Zoltan Ujhelyi is currently offline Zoltan UjhelyiFriend
Messages: 392
Registered: July 2015
Senior Member
Hi,

after a lot of debugging, the idea I was missing, that local variables should be introduced by the JvmModelInferrer.

By making sure that the expression is produced inside a correctly inferred method I could introduce the missing locals.

Cheers,
Zoltán
Re: Migrating Xbase-using language to Xtext 2.4 [message #1062517 is a reply to message #1062058] Sat, 08 June 2013 07:58 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
On 06/05/2013 05:20 PM, Zoltan Ujhelyi wrote:
> Hi,
>
> after a lot of debugging, the idea I was missing, that local variables
> should be introduced by the JvmModelInferrer.
>
> By making sure that the expression is produced inside a correctly
> inferred method I could introduce the missing locals.

Hi

do you have some code to share please?

thanks in advance
Lorenzo

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it


Re: Migrating Xbase-using language to Xtext 2.4 [message #1062549 is a reply to message #1062517] Sat, 08 June 2013 21:30 Go to previous messageGo to next message
Zoltan Ujhelyi is currently offline Zoltan UjhelyiFriend
Messages: 392
Registered: July 2015
Senior Member
Hi,

I was doing this inside the code base of the EMF-IncQuery project, so I can show you the related code changes in the public repository: http://git.eclipse.org/c/incquery/org.eclipse.incquery.git/diff/plugins/org.eclipse.incquery.tooling.core/src/org/eclipse/incquery/tooling/core/generator/jvmmodel/PatternMatchEvaluatorClassInferrer.xtend?h=xtext-2.4&id=3366c6a2d7ec2aa2ee434698c6b7ea0a96c9954c

The important part is to make sure that the inferrer assigns a Java method to the XExpression, where the method parameters are the local variables of the source model (in our case we were even more tricky, as we calculated the set of variables used in the XExpression, and used that as parameters (this makes sense, as our language allows the creation of variable references without a corresponding definition).

I hope this helps,
Zoltán
Re: Migrating Xbase-using language to Xtext 2.4 [message #1062625 is a reply to message #1062549] Mon, 10 June 2013 07:06 Go to previous message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
On 06/08/2013 11:30 PM, Zoltan Ujhelyi wrote:
> Hi,
>
> I was doing this inside the code base of the EMF-IncQuery project, so I
> can show you the related code changes in the public repository:
> http://git.eclipse.org/c/incquery/org.eclipse.incquery.git/diff/plugins/org.eclipse.incquery.tooling.core/src/org/eclipse/incquery/tooling/core/generator/jvmmodel/PatternMatchEvaluatorClassInferrer.xtend?h=xtext-2.4&id=3366c6a2d7ec2aa2ee434698c6b7ea0a96c9954c
>
>
> The important part is to make sure that the inferrer assigns a Java
> method to the XExpression, where the method parameters are the local
> variables of the source model (in our case we were even more tricky, as
> we calculated the set of variables used in the XExpression, and used
> that as parameters (this makes sense, as our language allows the
> creation of variable references without a corresponding definition).
>
> I hope this helps,
> Zoltán

Thanks!

Unfortunately my context is different: I have custom XExpressions which
introduce variables, thus I really need something like
createLocalVarScope...

cheers
Lorenzo

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it


Previous Topic:Fillter predicate
Next Topic:How to get a Resource in a project
Goto Forum:
  


Current Time: Fri Apr 26 08:44:16 GMT 2024

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

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

Back to the top