Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo] For loop generate extra white line iterating on Set<Association>
[Acceleo] For loop generate extra white line iterating on Set<Association> [message #1807722] Thu, 06 June 2019 16:17 Go to next message
Vittorio Niespolo is currently offline Vittorio NiespoloFriend
Messages: 11
Registered: May 2019
Junior Member
Hi,
i have a really strange problem on my generated code. If i use the following function directly in mtl file with [file] tag i have no problem while if i use it in a template and i call it in [file] mtl i get this strange behavior.

Acceleo add a white line on each code line. I have tried with separator, trim but nothing changed.
Can you please help me?

Function:
[template public genChildGetterSetter(aClass : Class)]
[for(a : Association | aClass.getChildAssociations())]
/**
 * @return the [aClass.getChildClass(a).name.toUpperFirst()/]
 */
public Collection<[aClass.getChildClass(a).name/]> get[aClass.getTheChildPropertyName(a).toUpperFirst()/](){
	return [aClass.getTheChildPropertyName(a)/];
}
[/for]
[/template]


GetChildAssociations():
[query public getChildAssociations(arg0 : Class) : Set(Association)
	= invoke('it.mice.acceleogenerator.javaservice.AssociationJavaUtils', 'getChildAssociations(org.eclipse.uml2.uml.Class)', Sequence{arg0})
/]


Result:

/**

 * @return the ProdottoPerOrdine

 */

public Collection<ProdottoPerOrdine> getTheProdottoPerOrdine(){

	return theProdottoPerOrdine;

}


Expected:
/**
 * @return the ProdottoPerOrdine
 */
public Collection<ProdottoPerOrdine> getTheProdottoPerOrdine(){
	return theProdottoPerOrdine;
}

Re: [Acceleo] For loop generate extra white line iterating on Set<Association> [message #1807762 is a reply to message #1807722] Fri, 07 June 2019 16:28 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7679
Registered: July 2009
Senior Member
Hi

My recollection is that getting whitespace exactly right from non-trivial control structures is difficult if not impossible even if very long lines are used. IIRC the Acceleo documentation used to recommend a separate prettifying phase if you have very strong layout requirements.

Regards

Ed Willink
Re: [Acceleo] For loop generate extra white line iterating on Set<Association> [message #1807808 is a reply to message #1807762] Mon, 10 June 2019 08:17 Go to previous messageGo to next message
Vittorio Niespolo is currently offline Vittorio NiespoloFriend
Messages: 11
Registered: May 2019
Junior Member
Thank you for the answer but my question is opposite, i don't want that white lines. I really cannot understand why they are generated. Is it an acceleo's bug?
Re: [Acceleo] For loop generate extra white line iterating on Set<Association> [message #1807813 is a reply to message #1807808] Mon, 10 June 2019 09:32 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7679
Registered: July 2009
Senior Member
Hi

IMHO, anything that makes a tool unduly painful to use is an ergonomic bug, so yes it is at least an ergonomic bug.

The Acceleo documentation has extensive descriptions on when whitespace is generated, so you might be able to pin down which description is inconsistent with its implementation. If this identifies a simple bug it might be fixed; Acceleo is being maintained but not actively developed.

More realistically, you might abandon attempts to contort your Acceleo source code layout to get the whitespace right and instead generate many gratuitous new lines and then put the output through a very simple blank line filter. Where you really want a blank line you could arrange to mark it so that your blank filter converts it to a clean blank line.

Regards

Ed Willink
Previous Topic:M2T Ecore2XML / Ecore2JSON Tutorial/Guide/Help
Next Topic:Runner : Acceleo Plug-in Applications
Goto Forum:
  


Current Time: Sat Nov 09 05:23:50 GMT 2024

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

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

Back to the top