Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » [SOLVED] Names unique across files of the same folder
[SOLVED] Names unique across files of the same folder [message #641377] Thu, 25 November 2010 09:06 Go to next message
Florian Gessner is currently offline Florian GessnerFriend
Messages: 20
Registered: November 2010
Junior Member
Hallo all,

I've created a grammar with XText similar to the grammar of the getting started section of the xtext user manual. In this case it is possible to access entities across different files but I can also define entities with the same name in both files.

Is it possible to check that the name of an entity is unique accross files?.

Thanks and Best Regards
Florian

[Updated on: Fri, 26 November 2010 13:36]

Report message to a moderator

Re: Names unique across files of the same folder [message #641601 is a reply to message #641377] Fri, 26 November 2010 09:22 Go to previous messageGo to next message
Pierre-Alain BOURDIL is currently offline Pierre-Alain BOURDILFriend
Messages: 25
Registered: September 2010
Junior Member
Hi,

Validation may help you to check that entites name are unique acrros different namespace. Implement a method that check unicity of entities name in your DslJavaVAlidator :

exple :
@Check
	public void checkAttributeNameIsUnique(Attribute aAttribute){
		final String lName = aAttribute.getName();
		for (InterfaceMember sibling:((Interface)aAttribute.eContainer()).getMembers())
		{
			if (sibling instanceof Attribute)
			{
				if (((Attribute) sibling).getName().equals(lName)  &&  sibling != aAttribute)
				{
					error("duplicate name '" + lName +"'", WebIDLPackage.ATTRIBUTE__NAME);
				}
			}
		}
	}
Re: Names unique across files of the same folder [message #641648 is a reply to message #641377] Fri, 26 November 2010 13:36 Go to previous message
Florian Gessner is currently offline Florian GessnerFriend
Messages: 20
Registered: November 2010
Junior Member
Thaks for help. I solved this by using the global scope provider to get all relevant entities and check than the uniquness of the name.
Previous Topic:Create (Xtext-) Resource from String
Next Topic:Re: Reading multiple XML models of different XSD's
Goto Forum:
  


Current Time: Wed Apr 24 22:37:07 GMT 2024

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

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

Back to the top