Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Xtext] Scoping on objects at runtime
[Xtext] Scoping on objects at runtime [message #623034] Fri, 02 July 2010 09:03 Go to next message
Martin is currently offline MartinFriend
Messages: 5
Registered: June 2010
Location: Dresden
Junior Member
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
Re: [Xtext] Scoping on objects at runtime [message #623037 is a reply to message #623034] Sat, 03 July 2010 22:53 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
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
Re: [Xtext] Scoping on objects at runtime [message #623038 is a reply to message #623034] Sat, 03 July 2010 22:53 Go to previous message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
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
Previous Topic:[Xtext] Problem: Scoping on objects at runtime
Next Topic:EMF object serialization into xml
Goto Forum:
  


Current Time: Sat Apr 27 01:09:32 GMT 2024

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

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

Back to the top