Skip to main content



      Home
Home » Modeling » TMF (Xtext) » [Xbase] How to provide scope for a XBlockExpression
[Xbase] How to provide scope for a XBlockExpression [message #1385303] Thu, 05 June 2014 09:37 Go to next message
Eclipse UserFriend
Hi,

I am developing a DSL with Xtext 2.6 which is based on Xbase and I would like to do something like:

Concept Airport {
  Attributes {
    Text(9) name {
      Validate {//XBlockExpression}
    }
    Text(19) code {}
    Number(5) someNumber {}
  }
}


I have the grammar and the JvmModelInferrer and now I want to write some Xbase expressions inside the "Validate" block, basically all I want to have is access to the attributes defined within this Airport.

When I use the Content Assist inside the Validate body I only see keywords and that seems to be due to the fact that no types have been computed.

I have found lots of different Xbase classes (IFeatureScopeSession, FeatureScopes, IBatchTypeResolver, etc.) and no good guidance to how these interact and where I would have to implement my custom logic.

So, please, where should I start?

Thanks, Jan

[Updated on: Thu, 05 June 2014 09:38] by Moderator

Re: [Xbase] How to provide scope for a XBlockExpression [message #1385311 is a reply to message #1385303] Thu, 05 June 2014 10:20 Go to previous messageGo to next message
Eclipse UserFriend
On 05/06/2014 15:37, Jan Rosczak wrote:
> Hi,
> I am developing a DSL with Xtext 2.6 which is based on Xbase and I would
> like to do something like:
>
> Concept Airport {
> Attributes {
> Text(9) name {
> Validate {//XBlockExpression}
> }
> Text(19) code {}
> Number(5) someNumber {}
> }
> }
>
> I have the grammar and the JvmModelInferrer and now I want to write some
> Xbase expressions inside the "Validate" block, basically all I want to
> have is access to the attributes defined within this Airport.
>
> When I use the Content Assist inside the Validate body I only see
> keywords and that seems to be due to the fact that no types have been
> computed.
>
> I have found lots of different Xbase classes (IFeatureScopeSession,
> FeatureScopes, IBatchTypeResolver, etc.) and no good guidance to how
> this interact and where I would have to implement my custom logic.
>
> So, please, where should I start?
>

Hi

You should implement the JvmModelInferrer and map the concepts of your
DSL to the Jvm type model (e.g., fields, methods)... with that in place
scoping will work automatically once you set your XBlockExpression as
the "body" of a mapped method...

Have you looked at the domain model example?

cheers
Lorenzo

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it
Xtext Book:
http://www.packtpub.com/implementing-domain-specific-languages-with-xtext-and-xtend/book
Re: [Xbase] How to provide scope for a XBlockExpression [message #1385386 is a reply to message #1385311] Fri, 06 June 2014 01:11 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

thanks for that tip. I already had the JvmModelInferrer implemented, but missed the assignment to the "body" of a mapped method.
Do you know how I can adapt the scoping for my XBlockExpression, add something, remove somethings, etc. in Xbase 2.6, because it changed from 2.5?

Regards
Jan
Re: [Xbase] How to provide scope for a XBlockExpression [message #1386878 is a reply to message #1385386] Sun, 22 June 2014 04:24 Go to previous message
Eclipse UserFriend
On 06/06/2014 07:11, Jan Rosczak wrote:
> Hi,
>
> thanks for that tip. I already had the JvmModelInferrer implemented, but
> missed the assignment to the "body" of a mapped method.
> Do you know how I can adapt the scoping for my XBlockExpression, add
> something, remove somethings, etc. in Xbase 2.6, because it changed from
> 2.5?
>
> Regards
> Jan

Hi Jan

sorry for the late response.
I did something similar in this project:

https://github.com/LorenzoBettini/xtraitj/blob/master/xtraitj/src/xtraitj/scoping/XtraitjScopeProviderUtil.xtend

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it
Xtext Book:
http://www.packtpub.com/implementing-domain-specific-languages-with-xtext-and-xtend/book
Previous Topic:Tutorial about Quick Fixes
Next Topic:Dependency Between Xtext project and Java project
Goto Forum:
  


Current Time: Wed Jul 23 23:35:58 EDT 2025

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

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

Back to the top