Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Auto-insert Switch/Case & Do/While incorrect(This seems to be a recurring problem, auto-insertion of Switch/Case & Do/While)
icon4.gif  Auto-insert Switch/Case & Do/While incorrect [message #1089973] Mon, 19 August 2013 14:34 Go to next message
Tim Cook is currently offline Tim Cook
Messages: 12
Registered: September 2010
Junior Member
Eclipse Kepler Configuration
eclipse.buildId=4.3.0.M20130731-0800
eclipse.commands=-os
win32
-ws
win32
-arch
x86

org.eclipse.cdt (8.2.0.201306112328) "Eclipse C/C++ Development Tools"

*** Plug-in Registry:
org.eclipse.cdt (8.2.0.201306112328) "Eclipse C/C++ Development Tools" [Starting]

org.eclipse.cdt.core (5.5.0.201306112328) "C/C++ Development Tools Core" [Active]
org.eclipse.cdt.core.win32 (5.3.0.201306112328) "C/C++ Development Tools Core for Windows" [Resolved]
org.eclipse.cdt.core.win32.x86 (5.2.0.201306112328) "C/C++ Development Tools Core for Windows (x86)" [Resolved]


Background:

I have created a C/C++ Code Style Formatter Custom Profile based on the built-in
Whitesmiths profile.
I configured the custom profile to conform to our coding standard, using the preview
pane to verify the format. The preview pane is a great tool.

Next I configured the Editor Templates to use the formatter.

From Custom Formatter Profile (Braces tab):
   switch (bar)
   {
      case 0:
         ++bar;
         break;
      case 1:
         --bar;
      default:
      {
         bar += bar;
         break;
      }
   }

From Custom Formatter Profile (White Space tab):
switch (number)
{
   case RED:
      return GREEN;
   case GREEN:
      return BLUE;
   case BLUE:
      return RED;
   default:
      return BLACK;
}

while (condition)
{
}
do
{
}
while (condition);

From Templates Preview:
switch (${key}) {
   case ${value}:
      ${line_selection}${cursor}
      break;
   default:
      break;
}

do {
   ${line_selection}${cursor}
} while (${condition});



ISSUE:
Most of the supported templates are inserted a expected. I have found two templates
(switch/case, do/while) which do not conform to the configured formatter options
when auto-inserted.

I was able to find possibly related bug report:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=246627
https://bugs.eclipse.org/bugs/show_bug.cgi?id=161024 (from 2006, subsequent reports marked a duplicate????!!!)

Inserted incorrect format:
switch (key)
{
   case value:
   
   break;
   default:
   break;
}

do
{
   
}while (condition);

Workaround:
I have disabled the "Use code formatter" option and updated each of the templates
to produce the desired results.

Am I missing something?


Thanks in advance for any response.

Sad Sad


Major System Configuration:
Windows 7 64-bit
Eclipse IDE for C/C++ Developers
v 4.3(Kepler)
MinGW
MSys
GNU Toolchain
SVN
Re: Auto-insert Switch/Case & Do/While incorrect [message #1090744 is a reply to message #1089973] Tue, 20 August 2013 15:22 Go to previous message
Axel Mueller is currently offline Axel Mueller
Messages: 1949
Registered: July 2009
Senior Member
The bug reports you listed are for JDT the Java editor.

But there is indeed a problem in the CDT code templates with respect to code formatter
https://bugs.eclipse.org/bugs/show_bug.cgi?id=244912


Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
Previous Topic:warning
Next Topic:Symbol 'NULL' could not be resolved
Goto Forum:
  


Current Time: Tue Sep 16 13:28:06 GMT 2014

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

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