Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Duplicate Names Across Files
Duplicate Names Across Files [message #684287] Wed, 15 June 2011 11:08 Go to next message
Christian Gudrian is currently offline Christian GudrianFriend
Messages: 11
Registered: May 2011
Junior Member
Hello!

In its standard configuration Xtext resolves cross references across file boundaries, yet it is possible to define two entities with the same name in two different files without Xtext complaining. What do I need to change to have Xtext check for duplicate names across file boundaries?

BTW, I'm running Xtext 2.

Thanks,

Christian
Re: Duplicate Names Across Files [message #684289 is a reply to message #684287] Wed, 15 June 2011 11:16 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

I believe there is no out of the box support for this scenario. You could make use of the index in order to complain about duplicate names.

Alex


Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
Re: Duplicate Names Across Files [message #684296 is a reply to message #684289] Wed, 15 June 2011 11:28 Go to previous messageGo to next message
Christian Gudrian is currently offline Christian GudrianFriend
Messages: 11
Registered: May 2011
Junior Member
Hi, Alex!

Quote:
I believe there is no out of the box support for this scenario.


What would be a feasible approach to generate unique qualified names?

Should I encorporate the file name into the qualified name? That would require either file names that are itself qualified names or some sort of name mangling which might again introduce name conflicts.

Or is it always a good idea to implement some kind of package/import mechanism into the DSL?

Christian
Re: Duplicate Names Across Files [message #684317 is a reply to message #684296] Wed, 15 June 2011 11:54 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

namespaces (e.g. by using packages) are the way to go. The basic problem remains, though as you have to ensure uniqueness of the qualified name (or global uniqueness of the package name).

Alex


Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
Re: Duplicate Names Across Files [message #684741 is a reply to message #684317] Thu, 16 June 2011 06:40 Go to previous messageGo to next message
Christian Gudrian is currently offline Christian GudrianFriend
Messages: 11
Registered: May 2011
Junior Member
Hi, Alex!

Quote:
The basic problem remains


How then are ambiguous cross references resolved by the linker? If two resources A and B both define an entity with the qualified name Q which get referenced by resource C, which one (A's Q or B's Q) ends up being linked to?

Christian

[Updated on: Thu, 16 June 2011 06:41]

Report message to a moderator

Re: Duplicate Names Across Files [message #684745 is a reply to message #684741] Thu, 16 June 2011 07:03 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

there is a layered scope concept (inner scopes is searched, if no element is found go to outer scope and so on). The default behaviour should be that there are two equally named elements in the same scope, they hide each other. For the global scope, this means that none of the two should be linked (however with the error message "could not resolve reference" rather than "there are several elements with that name"). Just try it out.

Alex


Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
Re: Duplicate Names Across Files [message #684796 is a reply to message #684745] Thu, 16 June 2011 09:19 Go to previous message
Christian Gudrian is currently offline Christian GudrianFriend
Messages: 11
Registered: May 2011
Junior Member
Hi, Alex!

Quote:
For the global scope, this means that none of the two should be linked.


Nope. The linker chooses one instance and links to it without complaint.

Christian

Previous Topic:Text file encoding and guillemets
Next Topic:[Xtext 2.0 / Xtend2] Missing methods in API
Goto Forum:
  


Current Time: Thu Apr 25 00:09:48 GMT 2024

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

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

Back to the top