Bug 502177 - Protected area removes hand written code/character
Summary: Protected area removes hand written code/character
Status: RESOLVED FIXED
Alias: None
Product: Acceleo
Classification: Modeling
Component: Core (show other bugs)
Version: 3.6.0   Edit
Hardware: All All
: P3 major
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-09-26 11:08 EDT by Johan Hardy CLA
Modified: 2016-09-27 10:58 EDT (History)
4 users (show)

See Also:


Attachments
Possible but constrainful warkaround (7.94 KB, image/png)
2016-09-26 11:08 EDT, Johan Hardy CLA
no flags Details
Acceleo project reproducing the issue (17.43 KB, application/x-zip-compressed)
2016-09-27 06:33 EDT, Johan Hardy CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Johan Hardy CLA 2016-09-26 11:08:06 EDT
Created attachment 264419 [details]
Possible but constrainful warkaround

When a protected area finishes with a closing bracket and line feed (LF):

{ \<LF>
    int a, b, c; \<LF>
    a = 1; \<LF>
    b = 2; \<LF>
    c = a + b; \<LF>
}<LF>

The closing bracket is removed and the protected body becomes:

{ \<LF>
    int a, b, c; \<LF>
    a = 1; \<LF>
    b = 2; \<LF>
    c = a + b; \<CR><LF>
<LF>

The only way to keep the closing bracket (last character of the body) is to add a CR like :

{ \<LF>
    int a, b, c; \<LF>
    a = 1; \<LF>
    b = 2; \<LF>
    c = a + b; \<CR><LF>
}<LF>

This bug is major because it modifies the protected area and removes character(s). The typical use case in C is a macro-like function:

#define DB_COMPARE_VALUES(value_1, value_2, result) \
/* Start of user code for DB_COMPARE_VALUES */ \
{ \
    if ((value_1) < (value_2)) \
    { \
        /* result is DB_LOWER if value 1 is lower than value 2 */ \
        (result) = DB_LOWER; \
    } \
    else if ((value_1) > (value_2)) \
    { \
        /* result is DB_HIGHER if value 1 is higher than value 2 */ \
        (result) = DB_HIGHER; \
    } \
    else \
    { \
        /* result is DB_EQUAL otherwise */ \
        (result) = DB_EQUAL; \
    } \
}
/* End of user code for DB_COMPARE_VALUES */
Comment 1 Laurent Goubet CLA 2016-09-27 05:00:30 EDT
This cannot be reproduced from our side. Could you provide us with a reproducible test case?
Comment 2 Johan Hardy CLA 2016-09-27 06:33:44 EDT
Created attachment 264446 [details]
Acceleo project reproducing the issue

Please find in attachment a very simple Acceleo project with one launcher that reproduce the issue. UML2 and Acceleo 3.6.1 has been used to reproduce it.
Comment 3 Laurent Goubet CLA 2016-09-27 10:39:21 EDT
Thans for the test case.

Bug was due to a regex that was a little too permissive on its match, and would have happened on any protected area which contained the chars "\n" and "}" in succession.
Comment 4 Johan Hardy CLA 2016-09-27 10:42:29 EDT
Great, this was exactly what I was thinking because it only happens with "}".
Comment 5 Eclipse Genie CLA 2016-09-27 10:58:48 EDT
New Gerrit change created: https://git.eclipse.org/r/82000