Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » newLineifNotEmpty on Generator(How to avoid newLineifNotEmpty in Generator.java)
newLineifNotEmpty on Generator [message #966006] Wed, 31 October 2012 17:26 Go to next message
Cristiano De Faveri is currently offline Cristiano De Faveri
Messages: 13
Registered: August 2012
Junior Member
Hi,

I have this code on Generator.xtend

	def dispatch compile(hql.QualifiedName qualifiedName) '''
		«FOR e: qualifiedName.qualifiers SEPARATOR '.'»
			«e.compile»
		«ENDFOR»
	'''

When compiling for Generator.java, a code to insert newline is written

 protected CharSequence _compile(final QualifiedName qualifiedName) {
    StringConcatenation _builder = new StringConcatenation();
    {
      EList<QualifiedElement> _qualifiers = qualifiedName.getQualifiers();
      boolean _hasElements = false;
      for(final QualifiedElement e : _qualifiers) {
        if (!_hasElements) {
          _hasElements = true;
        } else {
          _builder.appendImmediate(".", "");
        }
        CharSequence _compile = this.compile(e);
        _builder.append(_compile, "");
       _builder.newLineIfNotEmpty();  // ---> This should not be here
      }
    }
    return _builder;
  }


This newLineifNotEmpty method is inserting a extra space on my string

Ex:if I have two elements on qualifiedName, like a.b, generator is writing a.<space>b

How do I guide xtend to not generate this newLineifNotEmpty call ?

thanks in advance
Re: newLineifNotEmpty on Generator [message #966017 is a reply to message #966006] Wed, 31 October 2012 17:36 Go to previous message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6385
Registered: July 2009
Senior Member
Hi what about:

«qualifiedName.qualifiers.map[compile].join(".")»
Previous Topic:Bringing Xtext (or parts of it) to the web
Next Topic:Xbase and changed package names ?
Goto Forum:
  


Current Time: Thu Oct 23 20:34:21 GMT 2014

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

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