Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » limit cross reference boundary by scoping
limit cross reference boundary by scoping [message #834985] Mon, 02 April 2012 16:41 Go to next message
Phil R is currently offline Phil RFriend
Messages: 99
Registered: September 2011
Member
Hi,

currently a scope block is limited by a name attribute. e.g:
Scopeblock:
name=ID content=Content '.'
;

then each content belongs to a scopeblock by its name, thus all crossreferences without fqn (like: [referenceTo|ID]) do not get access to elements in the parent of the Scopeblock but only to elements defined in the scopeblock. Now when no name is used then the fqn of the defined elements in the Content rule are all like "parentofscopeblock.element" and then the elements are accessible from outside the content rule. Is it possible to also limit the boundary of the crossreference in this case? I tried custom scoping with the scopeprovider, but I got stuck. The Content rule is a complex rule which makes it even harder..
The defined xtext:
Model: blocks+=Scopeblock*

Scopeblock:
 content=Content '.'
;

Content: 
  couple of parser rules with crossreferences to Variable..
 | Variable
;

Variable:  name = ID;


Any suggestions? Or an example when using custom scope because I couldn't find it with custom scoping unfortunately..

Regards,
Phil
Re: limit cross reference boundary by scoping [message #835007 is a reply to message #834985] Mon, 02 April 2012 17:22 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi,

i am not sure what you want to achieve can you come up with a sample model and a description how the scopes should look like too?

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Mon, 02 April 2012 17:24]

Report message to a moderator

Re: limit cross reference boundary by scoping [message #835025 is a reply to message #835007] Mon, 02 April 2012 17:49 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
P.S: maybe you want to do something simple like

IScope scope_Variable_ref(Scopeblock context, EReference ref) {
return Scopes.scopeFor(EcoreUtil2.getAllContentsOfType(context, Variable.class));
}


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: limit cross reference boundary by scoping [message #835059 is a reply to message #835025] Mon, 02 April 2012 18:44 Go to previous message
Phil R is currently offline Phil RFriend
Messages: 99
Registered: September 2011
Member
Hi Christian,

Your example helped me a lot! I didn't know about the EcoreUtil2.getAllContentsOfType function. Thank you Christian! My problem is solved by using that function Wink

Regards,
Phil
Previous Topic:Outline does not work
Next Topic:Hover
Goto Forum:
  


Current Time: Thu Mar 28 20:01:45 GMT 2024

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

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

Back to the top