Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Trying to create Reverse cross-reference index(reverse cross reference index)
Trying to create Reverse cross-reference index [message #1714449] Thu, 12 November 2015 18:04 Go to next message
Siva Gaddam is currently offline Siva GaddamFriend
Messages: 22
Registered: June 2015
Junior Member
Hi,

I'm trying to create reverse reference index for the grammar like below.

Bid:
entityName='BID' name=INTID '{' attributes+=(BidAttribute | ProfileAttribute)* '}'
;
BidAttribute:
(BidRidAttribute)
;

BidRidAttribute:
attributeName='rid' ':' '{' rids+=[Rid|INTID] (',' rids+=[Rid|INTID])* '}'
;

Rid:
entityName='RID' name=INTID '{' (attributes+=(RidAttribute | ProfileAttribute))* '}'
;

Is there anyway I can get all bid references for a given rid?

Re: Trying to create Reverse cross-reference index [message #1714451 is a reply to message #1714449] Thu, 12 November 2015 18:21 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14337
Registered: July 2009
Senior Member
The xtext index iresoucedescriptions contains a set of i resourcedescription which have a list of ireferencedescruptions which are source target pairs

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Trying to create Reverse cross-reference index [message #1714463 is a reply to message #1714451] Thu, 12 November 2015 20:11 Go to previous messageGo to next message
Siva Gaddam is currently offline Siva GaddamFriend
Messages: 22
Registered: June 2015
Junior Member
Hi Christian,

Thank you very much for quick reply. Not sure I understood correctly. I'm sorry for being dumb. Is there anyway you can paste some sample code?
Re: Trying to create Reverse cross-reference index [message #1714471 is a reply to message #1714463] Thu, 12 November 2015 21:26 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14337
Registered: July 2009
Senior Member
https://www.eclipse.org/forums/index.php/m/1154764/?srch=ireferencedescription#msg_1154764
https://www.eclipse.org/forums/index.php?t=msg&th=1069616&goto=1706907&#msg_1706907


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Trying to create Reverse cross-reference index [message #1714475 is a reply to message #1714471] Thu, 12 November 2015 22:35 Go to previous messageGo to next message
Siva Gaddam is currently offline Siva GaddamFriend
Messages: 22
Registered: June 2015
Junior Member
Thanks alot. I'm not sure how does this work. Here is the snippet I have tried

def getReferencedResourceDescriptions(EObject o){
val index = rdp.getResourceDescriptions(o.eResource)
val rd = index.getResourceDescription(o.eResource.URI)
val referenceList = rd.referenceDescriptions.toList

}
Reference list is having the ones it refers too but not the ones who referred it. I'm looking for a list of entities who cross-referrenced the given object.

I really appreciate your help.

Thanks

[Updated on: Thu, 12 November 2015 22:37]

Report message to a moderator

Re: Trying to create Reverse cross-reference index [message #1714482 is a reply to message #1714475] Fri, 13 November 2015 04:54 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14337
Registered: July 2009
Senior Member
Hi i cannot do the coding for you

(1) obtain all iresourcedescription
(2) iterate through all reference descriptions
(3) filter them for the target object uri being the uri of the object you look for


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Trying to create Reverse cross-reference index [message #1714489 is a reply to message #1714482] Fri, 13 November 2015 07:32 Go to previous messageGo to next message
Siva Gaddam is currently offline Siva GaddamFriend
Messages: 22
Registered: June 2015
Junior Member
I'm sorry christian. I thought there is a simpler way to achieve this instead of iterating though every time.

Anyhow, thanks for the help.
Re: Trying to create Reverse cross-reference index [message #1714490 is a reply to message #1714489] Fri, 13 November 2015 07:34 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14337
Registered: July 2009
Senior Member
depending on your usecase you may have a look at IReferenceFinder

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Trying to create Reverse cross-reference index [message #1714596 is a reply to message #1714490] Fri, 13 November 2015 18:23 Go to previous messageGo to next message
Siva Gaddam is currently offline Siva GaddamFriend
Messages: 22
Registered: June 2015
Junior Member
Initially, I tried creating inverted index by extending DefaultResourceDescriptionStrategy like below.

override createEObjectDescriptions(EObject eObject, IAcceptor<IEObjectDescription> acceptor) {
if (eObject != null) {
switch (eObject) {
Bid: {
val Bid bid = eObject as Bid
val fullyQualifiedName = bid.fullyQualifiedName
// Go through each cross references and add the bid to its user data keys
bid.attributes.filter(Rid).forEach[R | EObjectDescription::create(R.fullyQualifiedName, R, newHashMap("bid"->bid.name))]
true
}
}

I thought this way, we can have inverted index as well along with the xtext generated index. For some reason I'm unable to get the actual RID object located in different file.
Re: Trying to create Reverse cross-reference index [message #1714606 is a reply to message #1714596] Fri, 13 November 2015 20:14 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14337
Registered: July 2009
Senior Member
Hi indexing is done before linking thus you cannot access cross refs when indexing

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Trying to create Reverse cross-reference index [message #1714607 is a reply to message #1714606] Fri, 13 November 2015 20:24 Go to previous message
Siva Gaddam is currently offline Siva GaddamFriend
Messages: 22
Registered: June 2015
Junior Member
That explains it. Thanks a lot for the help. I implement the naive way for now.
Previous Topic:Java 64K limitation in generated internal Lexer and other issues
Next Topic:Cross-file reference problem
Goto Forum:
  


Current Time: Fri Aug 12 01:05:44 GMT 2022

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

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

Back to the top