Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » XText nature and cross references
XText nature and cross references [message #1792229] Thu, 12 July 2018 21:49 Go to next message
Steve Hickman is currently offline Steve HickmanFriend
Messages: 56
Registered: August 2017
Member
I'm using ObeoDesigner 10.1.2 Community Edition with the XText Complete SDK 2.14.v20180523-0937.

I've created an XText grammar/DSL that's fairly large (~1300 lines including some comments). I've generated the artifacts and have a model in the (dm3entry) language that's also fairly large (6460 lines ). The model has a significant amount of internal cross-referencing. The model was generated by converting an XMI file into the dm3entry DSL format per a StackOverflow response from Sven Efftinge on this topic. (the link for which I'm apparently not allowed to paste as part of the initial post)

I followed the instructions in the XText 15 minutes tutorial by opening a new instance, then creating an new Java project, and then a file in that project with the appropriate extension (.dm3entry), which in turn triggered the question about adding an XText nature to the project - which I did. I then copied the dm3entry model file I generated from the XMI into this project's src directory (and refreshed).

When I open the file in the project it has many unresolved cross references. However, if I open the original file (same content) which is in a different directory and not part of the project, the file appears to parse correctly (the Outline is complete) but I don't get cross reference errors. I can fix the cross reference errors by using the FQNs of the objects - but I'd prefer not to because that's pretty verbose. And it is apparently unnecessary since one of the files appears to resolve the cross references using only the final segment of the element FQN.

Why is this happening? Is this to be expected? And, if not, how do I fix it? Do I just not create a project? Create a project but not give it an XText nature? Fix my code? I'm really baffled.

Other info that might be relevant: I have already created feature projects for this DSL and installed them in the same copy of ObeoDesigner that I'm using for development (a prior version). I don't know if that is interfering with what I'm doing.

Also, I had to create my own QualifiedNameProvider since several of the types in the model don't have a 'name' attribute. I've also got a custom ScopeProvider and ProposalProvider. All those appear to work correctly.
Re: XText nature and cross references [message #1792263 is a reply to message #1792229] Fri, 13 July 2018 16:17 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

i am not sure if i get your problem.

(1) if the model project is a java project then the model file has to be in a source folder
(2) the project needs xtext nature and xtext builder (.project file)
(3) build automatically should be enabled.
(4) if you open an external file there will be no validation of crefs

=> i dont know how your projects differ

(4) if you can fix the problem by using qualified names but you dont want to then you nameprovider impl is wrong.
so it would be interesting to know how you implemented it (e.g. subclass of simplenameprovider)


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: XText nature and cross references [message #1792270 is a reply to message #1792263] Fri, 13 July 2018 17:47 Go to previous message
Steve Hickman is currently offline Steve HickmanFriend
Messages: 56
Registered: August 2017
Member
Thank you so much for your rapid reply. I realized several things after submitting this post:
1) I misunderstood what was happening when I stated: ' I open the original file (same content) which is in a different directory and not part of the project, the file appears to parse correctly (the Outline is complete) but I don't get cross reference errors'. I now see that there was enough parsing going on to create the outline (with knowledge of what the individual language elements are) but there was no attempt to do any cross referencing at all (and thus no detection of cross reference errors) - as you state above. (For anyone else reading this post, I was able to determine this by selecting a cross reference and then using the context menu command 'Find References'. In the XText project with corrected cross references, it displays a list of those references. When executed on a reference in the file that is not part of the XText project, nothing is displayed.) I assume the XText nature is what triggers the cross reference validation.
2) I have to use at least relative qualified names anyway because there is a not insignificant risk of name duplication if I use leaf names only.

Given that, I'm in the process of updating my XMI import mechanism to insert the relative qualified name for each cross reference using an instance of the qualified name provider I created (in which I have added a method to calculate relative qualified names because I couldn't remember where the existing library code was that does this). My initial aversion to using qualified names was due solely to the fact that the longer the text of the cross reference, the harder the model as a whole is to read. I'm trying to make the resulting model as easy to read as possible.

To answer your questions: My QNP extends DefaultDeclarativeQualifiedNameProvider in the standard way as indicated in the doc.

My apologies for the premature post.
Previous Topic:Enforce build of model project first
Next Topic:LanExpressions
Goto Forum:
  


Current Time: Sat Apr 20 02:48:39 GMT 2024

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

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

Back to the top