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 13:37 |
Jan Rosczak Messages: 53 Registered: July 2009 Location: Hamburg, Germany |
Member |
|
|
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 13:38] Report message to a moderator
|
|
|
Re: [Xbase] How to provide scope for a XBlockExpression [message #1385311 is a reply to message #1385303] |
Thu, 05 June 2014 14:20 |
|
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
HOME: http://www.lorenzobettini.it
TDD Book: https://leanpub.com/tdd-buildautomation-ci
Xtext Book: https://www.packtpub.com/application-development/implementing-domain-specific-languages-xtext-and-xtend-second-edition
|
|
| |
Re: [Xbase] How to provide scope for a XBlockExpression [message #1386878 is a reply to message #1385386] |
Sun, 22 June 2014 08:24 |
|
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
HOME: http://www.lorenzobettini.it
TDD Book: https://leanpub.com/tdd-buildautomation-ci
Xtext Book: https://www.packtpub.com/application-development/implementing-domain-specific-languages-xtext-and-xtend-second-edition
|
|
|
Goto Forum:
Current Time: Wed Sep 18 22:06:55 GMT 2024
Powered by FUDForum. Page generated in 0.04261 seconds
|