Skip to main content


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 FaveriFriend
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 DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi what about:

«qualifiedName.qualifiers.map[compile].join(".")»


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Bringing Xtext (or parts of it) to the web
Next Topic:Xbase and changed package names ?
Goto Forum:
  


Current Time: Fri Apr 19 22:05:53 GMT 2024

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

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

Back to the top