Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » having empty line
having empty line [message #1222607] Fri, 20 December 2013 22:02 Go to next message
duke vah is currently offline duke vahFriend
Messages: 33
Registered: December 2013
Member
Hi,
When I call a template and it doesn't show anything, the Acceleo puts a full empty line for it. I used trim() in both the template and when I call it, but it doesn't work. Any help will be appreciated.
Check out the partial code and the generated code please:

I don't want to see Line 3 in the generated code when there is no attribute.

--------------------------------------------------------------
public:
[generateAttributes(VisibilityKind::public)/]
[generateConstructorsHeader(aClass)/]
[generateDesctuctorsHeader(aClass)/]
-----------------------------------------------------------------
[template public generateAttributes(aClass : Class, aVisibility : VisibilityKind) post (trim())]

[for (aProperty: Property | orderByContents( attribute->select(visibility=aVisibility)->asSequence() ) )]
[if (association->size()>0)][getAssociationInfo(aProperty)/]
[else]
[if (isStatic)]static [/if][getPropertyInfo(aProperty)/]
[/if]
[/for]
[/template]
------------------------------------------------------------------
------------------------------------------------------------------
1. class ClassB: public SuperClass{
2. public:
3.
4. //CONSTRUCTOR
5. ClassB();
6. //DESTRUCTOR
7. ~ClassB();
8.};
------------------------------------------------------------------
Re: having empty line [message #1223168 is a reply to message #1222607] Sun, 22 December 2013 16:40 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

It can be quite hard to get new-lines right. For non-trivial code
Acceleo recommends a separate pretty-printing pass.

If you really want to get it right you need to find out where the
unwanted new line comes from. My guess is that it follows either [/if]
or [/for]. You can then close up the text and you get what you want at
the expense of making your termplate less readable.

Regards

Ed Willink

On 20/12/2013 23:37, duke vah wrote:
> Hi,
> When I call a template and it doesn't show anything, the Acceleo puts
> a full empty line for it. I used trim() in both the template and when
> I call it, but it doesn't work. Any help will be appreciated.
> Check out the partial code and the generated code please:
>
> I don't want to see Line 3 in the generated code when there is no
> attribute.
>
> --------------------------------------------------------------
> public:
> [generateAttributes(VisibilityKind::public)/]
> [generateConstructorsHeader(aClass)/]
> [generateDesctuctorsHeader(aClass)/]
> -----------------------------------------------------------------
> [template public generateAttributes(aClass : Class, aVisibility :
> VisibilityKind) post (trim())]
>
> [for (aProperty: Property | orderByContents(
> attribute->select(visibility=aVisibility)->asSequence() ) )]
> [if (association->size()>0)][getAssociationInfo(aProperty)/]
> [else]
> [if (isStatic)]static [/if][getPropertyInfo(aProperty)/]
> [/if]
> [/for]
> [/template]
> ------------------------------------------------------------------
> ------------------------------------------------------------------
> 1. class ClassB: public SuperClass{
> 2. public:
> 3.
> 4. //CONSTRUCTOR
> 5. ClassB();
> 6. //DESTRUCTOR
> 7. ~ClassB();
> 8.};
> ------------------------------------------------------------------
>
Re: having empty line [message #1223216 is a reply to message #1223168] Sun, 22 December 2013 20:04 Go to previous messageGo to next message
duke vah is currently offline duke vahFriend
Messages: 33
Registered: December 2013
Member
Thanks for the response.
I have done this before but It didn't work. The issue is not with it. If for example I put nothing inside the template ("generateAttributes") and I call it, Acceleo considers a empty line for that calling again.
The only thing that I think works for this is checking by "if" but It is not good for the performance because I do checking based on for and it works very well. I think there should have been a nice command for the purpose.
Re: having empty line [message #1228486 is a reply to message #1223216] Tue, 07 January 2014 10:31 Go to previous message
Stephane Begaudeau is currently offline Stephane BegaudeauFriend
Messages: 458
Registered: April 2010
Location: Nantes (France)
Senior Member

Hi,

The rules followed by Acceleo for blank lines can be found here.

Regards,

Stephane Begaudeau, Obeo

--
Twitter: @sbegaudeau
Google+: +stephane.begaudeau
Blog: http://stephanebegaudeau.tumblr.com | Eclipse Java Development Tools Tips and Tricks
Previous Topic:Howto use Acceleo with a UML Profile
Next Topic:[Acceleo] Error Getting Attributes with Specific Stereotypes
Goto Forum:
  


Current Time: Thu Mar 28 09:37:37 GMT 2024

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

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

Back to the top