Skip to main content



      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 10:32 Go to next message
Eclipse UserFriend
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 10:37 Go to previous messageGo to next message
Eclipse UserFriend
you have to adapt the iqualifiednameprovider and use the node model to give the element its cross referernce as name
Re: Cross Referencing an already crossreferenced element in xtext doesn't work [message #1745792 is a reply to message #1745789] Mon, 17 October 2016 10:42 Go to previous messageGo to next message
Eclipse UserFriend
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 11:04 Go to previous messageGo to next message
Eclipse UserFriend
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)
}
}
Re: Cross Referencing an already crossreferenced element in xtext doesn't work [message #1745841 is a reply to message #1745797] Tue, 18 October 2016 05:44 Go to previous messageGo to next message
Eclipse UserFriend
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 06:12 Go to previous messageGo to next message
Eclipse UserFriend
Can you share a complete sample
Re: Cross Referencing an already crossreferenced element in xtext doesn't work [message #1745851 is a reply to message #1745842] Tue, 18 October 2016 07:35 Go to previous messageGo to next message
Eclipse UserFriend
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 12:25 Go to previous message
Eclipse UserFriend
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.

Previous Topic:XtextActivator instead of <MyLang>Activator
Next Topic:customise plugin.xml
Goto Forum:
  


Current Time: Mon May 12 20:55:29 EDT 2025

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

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

Back to the top