Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 453926

Summary: Provide @formatter:off to the CDT code formatter
Product: [Tools] CDT Reporter: Sharon Dagan <sharon.dagan>
Component: cdt-editorAssignee: Project Inbox <cdt-editor-inbox>
Status: CLOSED DUPLICATE QA Contact: Anton Leherbauer <aleherb+eclipse>
Severity: normal    
Priority: P3 CC: cdtdoug, marc.khouzam, oxoxon, waav_zoungla-efc7, zeratul976
Version: Next   
Target Milestone: ---   
Hardware: PC   
OS: All   
Whiteboard:

Description Sharon Dagan CLA 2014-12-02 14:44:59 EST
Provide @formatter:off support, as in JDT.
This features allows the user to exclude areas of the source code from being automatically formatted by the code formatter (i.e., with CMD+SHIFT+F). It works by placing an opening and closing comment.

... Code
...
...
// @formatter:off
// this section will be excluded from the formatter
...
...
...
// @formatter:on
...
...
...
Comment 1 Akira Okumura CLA 2015-02-03 10:34:42 EST
I need this feature too. When I have the following code formatted for example, I get an unwilling result which is difficult to understand the structure of the bit operations in the code.

--- Before ---
    CI[ 5] = D[13] ^ D[12] ^ D[11] ^ D[ 9] ^ D[ 8] ^ D[ 5] ^ D[ 4] ^ D[ 0] ^
             C[ 0] ^ C[ 4] ^ C[ 5] ^ C[ 8] ^ C[ 9] ^ C[11] ^ C[12] ^ C[13];
    CI[ 6] = D[14] ^ D[13] ^ D[12] ^ D[10] ^ D[ 9] ^ D[ 6] ^ D[ 5] ^ D[ 1] ^
             C[ 1] ^ C[ 5] ^ C[ 6] ^ C[ 9] ^ C[10] ^ C[12] ^ C[13] ^ C[14];

--- After ---
    CI[5] = D[13] ^ D[12] ^ D[11] ^ D[9] ^ D[8] ^ D[5] ^ D[4] ^ D[0] ^ C[0]
        ^ C[4] ^ C[5] ^ C[8] ^ C[9] ^ C[11] ^ C[12] ^ C[13];
    CI[6] = D[14] ^ D[13] ^ D[12] ^ D[10] ^ D[9] ^ D[6] ^ D[5] ^ D[1] ^ C[1]
        ^ C[5] ^ C[6] ^ C[9] ^ C[10] ^ C[12] ^ C[13] ^ C[14];

Here is another example. The difference between 4 lines become unclear after formatting.
--- Before ---
  if (asic == 0) {
    WriteRegisterPartially(0x4D, channel,      channel,      enable ? 0x1 : 0x0);
  } else if (asic == 1) {
    WriteRegisterPartially(0x4D, channel + 16, channel + 16, enable ? 0x1 : 0x0);
  } else if (asic == 2) {
    WriteRegisterPartially(0x4E, channel,      channel,      enable ? 0x1 : 0x0);
  } else if (asic == 3) {
    WriteRegisterPartially(0x4E, channel + 16, channel + 16, enable ? 0x1 : 0x0);
  }

--- After ---
  if (asic == 0) {
    WriteRegisterPartially(0x4D, channel, channel, enable ? 0x1 : 0x0);
  } else if (asic == 1) {
    WriteRegisterPartially(0x4D, channel + 16, channel + 16,
        enable ? 0x1 : 0x0);
  } else if (asic == 2) {
    WriteRegisterPartially(0x4E, channel, channel, enable ? 0x1 : 0x0);
  } else if (asic == 3) {
    WriteRegisterPartially(0x4E, channel + 16, channel + 16,
        enable ? 0x1 : 0x0);
  }
Comment 2 Nathan Ridge CLA 2015-03-31 05:12:51 EDT
This is essentially a duplicate of bug 327559, it's just a different syntax being asked for (@formatter:off vs. *INDENT-OFF*).
Comment 3 Amenel Voglozin CLA 2015-07-15 07:25:06 EDT
Would it be appropriate then that someone who has the rights/permissions to do this flags this bug entry as a duplicate of #327559? 
I'm asking because I am putting all of my votes on this feature request.
Comment 4 Nathan Ridge CLA 2015-07-15 10:54:23 EDT
(In reply to Amenel Voglozin from comment #3)
> Would it be appropriate then that someone who has the rights/permissions to
> do this flags this bug entry as a duplicate of #327559? 

Yes. (I don't.)

> I'm asking because I am putting all of my votes on this feature request.

You're welcome to do that, but given that this feature request has been open for almost 5 years and no one has implemented it yet, voting for it is not likely to have much effect. If you really want this feature, a more effective way to get it would be to contribute a patch that implements it yourself.
Comment 5 Marc Khouzam CLA 2015-07-15 13:37:58 EDT
(In reply to Nathan Ridge from comment #2)
> This is essentially a duplicate of bug 327559, it's just a different syntax
> being asked for (@formatter:off vs. *INDENT-OFF*).

*** This bug has been marked as a duplicate of bug 327559 ***