[Xtext] Problem: Scoping on objects at runtime [message #544293] |
Fri, 02 July 2010 05:03  |
Eclipse User |
|
|
|
I'am trying to to some kind of scoping. I have the following DSL:
Definition Name{
property Name_prop
property Name_prop1
}
Definition Test{
property Test_prop
}
Access Test {
propertyRef Test_prop
}
Now I want to press [Strg + Space] after 'propertyRef' and
I want to see just "Test_prop" as proposal in the context menu!
By default Xtext generates me 'Name_prop", "Name_prop1"
and "Test_prop" as proposal.
Is there any posibility to do that with Xtext? My grammar looks like this: (notice the {FunctionCall} was just a try to get access to the objects at runtime for scoping?)
Language returns Language:
(statement+=Statement)*;
Statement returns Statement:
Definition | Access;
Definition returns Definition:
'Definition'
name=DefName
'{'
(properties+=Property)*
'}';
DefName:
name = ID;
AbstractDefName:
Definition |DefName ;
Access returns Access:
'Access' {FunctionCall} DefinitionName=[AbstractDefName]
'{'
propAccesses+=PropAccess
'}';
PropAccess : 'propertyRef' propertyRef=[Property];
Property returns Property:
'property'
name=ID
;
EString returns ecore::EString:
STRING | ID("." ID)*;
If there is no way to do that automatically by using Xtext? What
API can I use to implement this feature? How to do that using the ScopeProvider?
Thanks and Regards,
Martin
[Updated on: Fri, 02 July 2010 11:52] by Moderator
|
|
|
|
Re: [Xtext] Scoping on objects at runtime [message #544562 is a reply to message #544293] |
Sat, 03 July 2010 18:53  |
Eclipse User |
|
|
|
Hi Martin,
something like
public IScope scope_PropAccess_propertyRef(Access context, EReference ref) {
Definition definition = // navigate from context to definition
return Scopes.scopeFor(definition.getProperties());
}
should do the trick. Have a look at the documentation to learn more
about scope providers.
Please note that Xtext has a dedicated newsgroup eclipse.modeling.tmf
Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Am 02.07.10 11:03, schrieb Martin:
> I'am trying to to some kind of scoping. I have the following DSL:
>
>
> Definition Name{
> property Name_prop
> property Name_prop1
> }
>
> Definition Test{
> property Test_prop
> }
>
> Access Test {
> propertyRef Test_prop }
>
>
> Now I want to press [Strg + Space] after 'propertyRef' and
> I want to see just "Test_prop" as proposal in the context menu!
> By default Xtext generates me 'Name_prop", "Name_prop1"
> and "Test_prop" as proposal.
>
> Is there any posibility to do that with Xtext? My grammar looks like
> this: (notice the {FunctionCall} was just a try to get access to the
> objects at runtime for scoping?)
>
>
> Language returns Language:
> (statement+=Statement)*;
>
> Statement returns Statement:
> Definition | Access;
>
> Definition returns Definition:
> 'Definition'
> name=DefName
> '{'
> (properties+=Property)*
> '}';
>
> DefName: name = ID;
>
> AbstractDefName:
> Definition |DefName ;
>
>
> Access returns Access:
> 'Access' {FunctionCall} DefinitionName=[AbstractDefName]
> '{'
> propAccesses+=PropAccess
> '}';
>
> PropAccess : 'propertyRef' propertyRef=[Property];
>
> Property returns Property:
> 'property'
> name=ID
> ;
>
> EString returns ecore::EString:
> STRING | ID("." ID)*;
>
>
> If there is no way to do that automatically by using Xtext? What
> API can I use to implement this feature? How to do that using the
> ScopeProvider?
>
> Thanks and Regards,
> Martin
|
|
|
Powered by
FUDForum. Page generated in 0.07351 seconds