Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo] Problem with the deleted protected zones
[Acceleo] Problem with the deleted protected zones [message #1769532] Tue, 01 August 2017 11:16 Go to next message
Mad Vin is currently offline Mad VinFriend
Messages: 38
Registered: September 2013
Member
Hello,

I'm using an old version of Acceleo (3.4.1) but i can't change it for now. I launch the generation as a Java application because the generator will be executed in standalone (outside Eclipse).

I have some errors of generation when a generated file owning protected zones is regenerated. A RejectedExecutionException is launched very often but not all the time... even if i comment some acceleo rules to generate nothing after having launched it once before, i can have this error too.

I have found this reported bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=380149#c10, which has been fixed on a later version of Acceleo. I've tried to use the alternative way described in the comments of this bug page which consists in calling the main module only once, but the problem is the root element of my model is a Package owning subpackages so the main module is called several times still.

With this solution, the RejectedExecutionException is not launched anymore, and i can regenerate the model without problem. But if i regenerate the model with some of the protected zones less, the generated file is emptied and i have the following error in the console each time the main model is called : "The file name used for the generation may be empty". But i don't know what to do to avoid this error.


Here is an example of the code producing this error :

[template public generateElement(pck : Package) ? (name = 'myPackage')]
[comment @main/]
[pck.ownedElement->filter(Class)->any(name = 'MyClass').genClass()/]
[/template]

[template public genClass(aClass : Class)]
[startFile()/]
[file ('debug.txt', false, 'UTF-8')]
[genOp()/]
[/file]
[endFile()/]
[/template]


I can launch the generation several times like this, it works. If i comment the genOp(), which generates several protected zones, after having launched the generation with it, i have the above error. And for an unknown reason, i can have too the RejectedExecutionException again instead of the "The file name used for the generation may be empty".

When i launch the generation as Acceleo Application, i have the same problem. I have the 2 problems at the same time : RejectedExecutionException and the message "The file name used for the generation may be empty".

Have you an alternative way to avoid these problems for this version of Acceleo as Java application ?

Thanks.

Regards.

[Updated on: Tue, 01 August 2017 11:39]

Report message to a moderator

Re: [Acceleo] Problem with the deleted protected zones [message #1769863 is a reply to message #1769532] Fri, 04 August 2017 09:44 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1858
Registered: July 2009
Senior Member
Hi,

I don't think this is a bug we've ever encountered on lost files, at least I don't remember about a bug corresponding to this description. I can't think of a reason you'd be getting these exceptions, so I can't really provide any hint towards a workaround. The 3.4 stream is no longer maintained apart from commercial support and quite a few bugs have been fixed since then. I'd highly suggest trying t o upgrade your environnement whenever possible .

Laurent Goubet
Obeo
Re: [Acceleo] Problem with the deleted protected zones [message #1769883 is a reply to message #1769863] Fri, 04 August 2017 13:35 Go to previous messageGo to next message
Mad Vin is currently offline Mad VinFriend
Messages: 38
Registered: September 2013
Member
Hi !

Thanks for the answer... For now, we cannot change the acceleo version. We think to do it later but we have some problems to analyze before with the RSA plugins and the later Acceleo version.

I have another strange problem with the protected zones with another generation main module with the same old version of Acceleo : the contents of the protected zones are ignored for an unknown reason. The start and end protected zones lines haven't changed, but their contents are deleted, and no lost files are created.

Here is the git diff :

 // Start of user code InitConstructor _ZDpG8DF_EeOp1LADIcvJIL
-                      : AbstractHandler(id, context),
-                        _startLocation(0),
-                        _endLocation(-1),
-                        _complementId(NULL),
-                        _transaction(0),
-                        _waitingMessage(NULL),
-                        _provider(NULL),
-                        _operation(NULL)
+// : 
+// AbstractHandler(),
+// _startLocation(),
+// _endLocation(),
+// _complementId(),
+// _transaction(),
+// _waitingMessage(),
+// _provider(),
+// _operation(),
 // End of user code
 {
 
     // Start of user code Constructor _ZDpG8DF_EeOp1LADIcvJIL
-    logInfo(INIT_LOG);
     // End of user code
 }


As you can see, the default contents of the protected zones are written, instead of keeping the previous ones. All the protected zones of the file are started and ended, and have different id. I have the same result by launching the generation in Java application or in Acceleo application, and no errors are reported in the console or in the Error Log view. I've never seen such a behaviour before. :/
Do you know what can lead to this problem ?

FYI : other files during the generation have lost some of their protected zones (this is a normal behaviour because some of their methods have been deleted from the model), and the lost files are created. So for these ones, it works well.

Thanks a lot for your support.

Regards.

[Updated on: Fri, 04 August 2017 13:38]

Report message to a moderator

Re: [Acceleo] Problem with the deleted protected zones [message #1769891 is a reply to message #1769883] Fri, 04 August 2017 15:54 Go to previous messageGo to next message
Mad Vin is currently offline Mad VinFriend
Messages: 38
Registered: September 2013
Member
I've found the origin of this second problem.

To avoid the generation of useless new lines, I call the template which create the protected zones like this :

[if protectedZoneCreatorTemplate().size() > 0]
[protectedZoneCreatorTemplate()/]

[/if]


It seems that Acceleo takes into account the protected zones created by the first call to the template inside the if condition expression, which are however not generated. With the second call to the template, Acceleo see 2 same protected zones in the file and so do not manage it correctly.

I think it should be considered as a bug because only one protected zone is created concretely, and there is no reason the call of the template in the if condition causes this problem (even if calling a template in a condition expression is not very... graceful... but the language enables it... so...)

I will test this in a more current version of Acceleo first, before to write a bug on bugzilla.

I've found also another bug with the generated end line of a protected zone : if we change the indentation of this line in the template, it is not taken into account during the regeneration, while it works well with the start line. I will test it first also on a more current version before to report a bug.

Regards.
Re: [Acceleo] Problem with the deleted protected zones [message #1770112 is a reply to message #1769891] Tue, 08 August 2017 13:07 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1858
Registered: July 2009
Senior Member
Hi,

I understand the issue about the "default content" being generated for your protected areas... and I am almost certain this bug will arise as well in recent versions since it had never been encountered and thus never fixed. I think, however, that there won't be any workaround for this save for reproducing the actual "if" that prevents the generation of protected areas instead of calling the template and checking for its size. If I remember correctly, Acceleo discards protected content once it's been re-generated and, in this case, we think it has been regenerated from the "if" call. A potential fix would be to keep the content in memory I guess.

As for the indentation, the protected content will always be preserved, be it indentation or content, so we won't alter the indentation of protected code even if you change the indentation in the template.

Laurent Goubet
Obeo
Re: [Acceleo] Problem with the deleted protected zones [message #1777902 is a reply to message #1769883] Tue, 05 December 2017 21:17 Go to previous message
Damián Rotta is currently offline Damián RottaFriend
Messages: 1
Registered: November 2017
Junior Member
A lot of time has passed but I'm facing the same problem. My workaround is, if you are generating code with Java-like comments, you can use "@generated NOT" annotation before the block which you want to protect.
Previous Topic:Acceleo : A solution for dependencies to another project with Java launcher
Next Topic:Running template just once for an Ecore model
Goto Forum:
  


Current Time: Thu Sep 20 14:26:19 GMT 2018

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

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

Back to the top