Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 353022 - AbortFormatting exception formatting switch without braces
Summary: AbortFormatting exception formatting switch without braces
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-core (show other bugs)
Version: 8.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 9.8.0   Edit
Assignee: Marco Stornelli CLA
QA Contact: Doug Schaefer CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-25 13:16 EDT by Marc-André Laperle CLA
Modified: 2019-05-18 02:16 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marc-André Laperle CLA 2011-07-25 13:16:27 EDT
Using CDT 8.0.0.201107220206

1. Paste this code in an editor:

void foo()
{
switch(0)
default:
{

}
}

2. Format the code (ctrl+shift+F)
3. Exception occurs:

org.eclipse.cdt.internal.formatter.AbortFormatting: [2/15] Unexpected token type, expecting:12, actual:Token type=71  image =default offset=23
	at org.eclipse.cdt.internal.formatter.Scribe.printNextToken(Scribe.java:1623)
	at org.eclipse.cdt.internal.formatter.CodeFormatterVisitor.formatOpeningBrace(CodeFormatterVisitor.java:3983)
	at org.eclipse.cdt.internal.formatter.CodeFormatterVisitor.visit(CodeFormatterVisitor.java:3458)
	at org.eclipse.cdt.internal.formatter.CodeFormatterVisitor.visit(CodeFormatterVisitor.java:950)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTSwitchStatement.accept(CPPASTSwitchStatement.java:95)
	at org.eclipse.cdt.internal.formatter.CodeFormatterVisitor.formatStatements(CodeFormatterVisitor.java:4040)
	at org.eclipse.cdt.internal.formatter.CodeFormatterVisitor.formatOpenedBlock(CodeFormatterVisitor.java:3939)
	at org.eclipse.cdt.internal.formatter.CodeFormatterVisitor.formatBlock(CodeFormatterVisitor.java:3914)
	at org.eclipse.cdt.internal.formatter.CodeFormatterVisitor.visit(CodeFormatterVisitor.java:1370)
	at org.eclipse.cdt.internal.formatter.CodeFormatterVisitor.formatDeclaration(CodeFormatterVisitor.java:646)
	at org.eclipse.cdt.internal.formatter.CodeFormatterVisitor.visit(CodeFormatterVisitor.java:636)
	at org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFunctionDefinition.accept(CPPASTFunctionDefinition.java:164)
	at org.eclipse.cdt.internal.formatter.CodeFormatterVisitor.formatDeclarations(CodeFormatterVisitor.java:506)
	at org.eclipse.cdt.internal.formatter.CodeFormatterVisitor.visit(CodeFormatterVisitor.java:450)
	at org.eclipse.cdt.internal.core.dom.parser.ASTTranslationUnit.accept(ASTTranslationUnit.java:271)
	at org.eclipse.cdt.internal.formatter.CodeFormatterVisitor.format(CodeFormatterVisitor.java:396)
	at org.eclipse.cdt.internal.formatter.CCodeFormatter.format(CCodeFormatter.java:158)
	at org.eclipse.cdt.internal.corext.util.CodeFormatterUtil.format(CodeFormatterUtil.java:129)
	at org.eclipse.cdt.internal.ui.text.CFormattingStrategy.format(CFormattingStrategy.java:62)
	at org.eclipse.jface.text.formatter.MultiPassContentFormatter.formatMaster(MultiPassContentFormatter.java:193)
Comment 1 Eclipse Genie CLA 2019-05-17 14:29:42 EDT
New Gerrit change created: https://git.eclipse.org/r/142349