Skip to main content


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
Missing name Mising name is currently offline Missing name Mising nameFriend
Messages: 35
Registered: September 2010
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.6.2 (Neon)
v 4.7.3a (Oxygen)
v 4.8r (Photon)
v 2018_09

PyDev

MinGW
MSys
GNU Toolchain
Perforce
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 MuellerFriend
Messages: 1973
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: Fri Apr 26 04:51:34 GMT 2024

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

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

Back to the top