Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Duplicate Names Across Files
Duplicate Names Across Files [message #684287] Wed, 15 June 2011 07:08 Go to next message
Eclipse UserFriend
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 07:16 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: Duplicate Names Across Files [message #684296 is a reply to message #684289] Wed, 15 June 2011 07:28 Go to previous messageGo to next message
Eclipse UserFriend
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 07:54 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: Duplicate Names Across Files [message #684741 is a reply to message #684317] Thu, 16 June 2011 02:40 Go to previous messageGo to next message
Eclipse UserFriend
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 02:41] by Moderator

Re: Duplicate Names Across Files [message #684745 is a reply to message #684741] Thu, 16 June 2011 03:03 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: Duplicate Names Across Files [message #684796 is a reply to message #684745] Thu, 16 June 2011 05:19 Go to previous message
Eclipse UserFriend
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: Tue Jul 08 20:04:12 EDT 2025

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

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

Back to the top