Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Cross Referencing an already crossreferenced element in xtext doesn't work
Cross Referencing an already crossreferenced element in xtext doesn't work [message #1745786] Mon, 17 October 2016 14:32 Go to next message
anudeep arya is currently offline anudeep aryaFriend
Messages: 49
Registered: March 2013
Member
Hi,

I have a simple grammar as shown below

ContainsPackage:
'Contains package' pkgRef=[CDPackage|FQN];

CDPackage:
'for' 'package' name=[ProjectCompPackage|FQN]

ProjectCompPackage:
'package' name=FQN '{'

'}';

I have 'Contains package' which has reference to CDPackage which inturn has reference to ProjectCompPackage.

When i try to create a DSL(instance) with this grammar,i cannot see anything in content assist for ContainsPackage though i have many CDPackages and Project ComponentPackages in my editor

Can i know if i am doing anything wrong.

In short does cross referenicng an already crossreferenced element work??If so can some one provide a small example which i can test.

Thanks in advance

Regards,
Anudeep
Re: Cross Referencing an already crossreferenced element in xtext doesn't work [message #1745789 is a reply to message #1745786] Mon, 17 October 2016 14:37 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14722
Registered: July 2009
Senior Member
you have to adapt the iqualifiednameprovider and use the node model to give the element its cross referernce as name

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: Cross Referencing an already crossreferenced element in xtext doesn't work [message #1745792 is a reply to message #1745789] Mon, 17 October 2016 14:42 Go to previous messageGo to next message
anudeep arya is currently offline anudeep aryaFriend
Messages: 49
Registered: March 2013
Member
Hello Christian,

Thanks for the quick response.

Can you provide a small example so that it would be more clear to me

Regards,
Anudeep
Re: Cross Referencing an already crossreferenced element in xtext doesn't work [message #1745797 is a reply to message #1745792] Mon, 17 October 2016 15:04 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14722
Registered: July 2009
Senior Member
sorry i dont have the time for that pseudo code

class MyQNP extends DefaultQualifiednameprovider {

@Inject iqualifiednameconverter qnc
def qualifiedName(CDPackage p) {
return qnc.toqualfiedname(NodeModelUtils.findnodeforfeature(p, Mydslpaclage.literals.CDPackage__name).head.text)
}
}


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: Cross Referencing an already crossreferenced element in xtext doesn't work [message #1745841 is a reply to message #1745797] Tue, 18 October 2016 09:44 Go to previous messageGo to next message
anudeep arya is currently offline anudeep aryaFriend
Messages: 49
Registered: March 2013
Member
Thanks christian

It is working fine for ID but not for FQN.
For the above example,i see the references appearing in Content Assist but the references are not resolved.

Incase of ID's i see everything working fine.Is there any reason for this??

Regards,
Anudeep.
Re: Cross Referencing an already crossreferenced element in xtext doesn't work [message #1745842 is a reply to message #1745841] Tue, 18 October 2016 10:12 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14722
Registered: July 2009
Senior Member
Can you share a complete sample

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: Cross Referencing an already crossreferenced element in xtext doesn't work [message #1745851 is a reply to message #1745842] Tue, 18 October 2016 11:35 Go to previous messageGo to next message
anudeep arya is currently offline anudeep aryaFriend
Messages: 49
Registered: March 2013
Member
Hi Christian,

For elements with FQN i did a trim for the text and it works perfectly fine

I don't know why but the text starts with a space and hence couldn't be resolved earlier.

I have written something like this
NodeModelUtils.findNodesForFeature(cdPackage, CdeplPackage.Literals.CD_PACKAGE__NAME).head.text.trim)

Thank you once again for the quick responses

Regards,
Anudeep.
Re: Cross Referencing an already crossreferenced element in xtext doesn't work [message #1746031 is a reply to message #1745851] Thu, 20 October 2016 16:25 Go to previous message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
The node model contains all leaf nodes for all tokens that were encountered when the respective element was parsed. That includes the hidden tokens for whitespace and comments.

So you should remove all hidden tokens from the list of nodes, e.g. (Xtend)

findNodesForFeautre(...)
.map[leafNodes]
.flatten
.filter[!hidden]
.map[text]
.join('.')

before passing the concatenated texts to the qualified name converter.



---
Get professional support from the Xtext committers at www.typefox.io
Previous Topic:XtextActivator instead of <MyLang>Activator
Next Topic:customise plugin.xml
Goto Forum:
  


Current Time: Wed Oct 09 19:41:12 GMT 2024

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

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

Back to the top