Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How to change the namespace separator ?
How to change the namespace separator ? [message #1132458] Fri, 11 October 2013 06:51 Go to next message
Vlad Gheorghe is currently offline Vlad GheorgheFriend
Messages: 127
Registered: May 2011
Senior Member

By default, the namespace separator in xtext is '.'

Which is the correct approach to change this to other strin e.g. "::') ?

I found in xtext the following variation points:

IQualifiedNameConverter - converts between QualifiedName and String. (parser / serializer)
IQualifiedNameProvider - "Provides qualified names for EObjects."
- uses IQualifiedNameConverter

QualifiedNameValueConverter - A value converter for qualified names consisting of segments or wildcard literals separated by namespace delimiters.
- provided by IValueConverterService


Also relevant is that a reference can be realized in the grammar as *either* a String Data Type or a QualifiedName data type.

The source of my confusion is that both the default implementation of IQualifiedNameConverter and QualifiedNameValueConverter have an own definition of the namespace separator, which defaults to '.' .

Which is used for what ?

Do both have to be overriden to customize the separator ?

Are the QualifiedNames used internally encoded as strings ?
( this is from interpreting the return type of
String QualifiedNameValueConverter#toValue(String string, INode node) ) ?


Cheers,
Vlad




Re: How to change the namespace separator ? [message #1133275 is a reply to message #1132458] Fri, 11 October 2013 19:03 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

what about simply changing both?

btw QualifiedNameValueConverter seems to be a xbase only thingy.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How to change the namespace separator ? [message #1137312 is a reply to message #1133275] Mon, 14 October 2013 12:00 Go to previous messageGo to next message
Vlad Gheorghe is currently offline Vlad GheorgheFriend
Messages: 127
Registered: May 2011
Senior Member
Hi Christian,

Quote:

what about simply changing both?

I've tried that, but with mixed results ( e.g. autocomplete still insists to provide '.'-separated names).

My main question is how is this supposed to be achieved *properly*.
(I can always code&fix, but I won't bother anyone on the forum with that..)

So could you kindly explain the intended use of these classes ?


Quote:

btw QualifiedNameValueConverter seems to be a xbase only thingy.


Why are you saying this ?
The full name is:
org.eclipse.xtext.conversion.impl.QualifiedNameValueConverter.class
and this is a concrete class.

It is extended by XbaseQualifiedNameValueConverter, indeed, but it's also exported from org.eclipse.xtect.

Best
Vlad


Re: How to change the namespace separator ? [message #1137364 is a reply to message #1137312] Mon, 14 October 2013 12:44 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

both are used as different places.

did you register the valueconverter for your qualifiedname rule?

the problem for autocompletion i dont understand.
did you debug the code...


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How to change the namespace separator ? [message #1344126 is a reply to message #1132458] Fri, 09 May 2014 16:21 Go to previous message
Alvaro Miyazawa is currently offline Alvaro MiyazawaFriend
Messages: 1
Registered: May 2014
Junior Member
I realise this thread is a bit old, but I got here with the same problem. I managed to solve this by extending the IQualifiedNameConverter.DefaultImpl as follows:
public class MyQualifiedNameConverter extends IQualifiedNameConverter.DefaultImpl {
	@Override
	public String getDelimiter() {
		return "::";
	}
}


and binding it to IQualifiedNameConverter in the language runtime module (e.g., MyDslRuntimeModule) by declaring the following method:
public Class<? extends IQualifiedNameConverter> bindIQualifiedNameConverter() {
	return MyQualifiedNameConverter.class;
}

I hope this helps.
Previous Topic:Problem with content assist icons
Next Topic:Override "names are unique" check for a specific type of object
Goto Forum:
  


Current Time: Thu Apr 18 09:44:19 GMT 2024

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

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

Back to the top