1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Bug 357423. Fixed regression.

This commit is contained in:
Sergey Prigogin 2011-09-20 17:28:53 -07:00
parent 745cbac9a9
commit c71e247578
2 changed files with 19 additions and 2 deletions

View file

@ -3526,14 +3526,14 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
* Controller expression
*/
IASTExpression controllerExpression = node.getControllerExpression();
if (!enclosedInMacroExpansion(controllerExpression)) {
if (!doNodesHaveSameOffset(node, controllerExpression)) {
scribe.printNextToken(Token.tLPAREN, preferences.insert_space_before_opening_paren_in_switch);
if (preferences.insert_space_after_opening_paren_in_switch) {
scribe.space();
}
}
controllerExpression.accept(this);
if (!enclosedInMacroExpansion(controllerExpression)) {
if (peekNextToken() == Token.tRPAREN) {
scribe.printNextToken(Token.tRPAREN, preferences.insert_space_before_closing_paren_in_switch);
}
/*

View file

@ -2658,6 +2658,23 @@ public class CodeFormatterTest extends BaseUITestCase {
assertFormatterResult();
}
//#define EXPR(a) a
//void f(){
//switch(EXPR(1)){default:break;}
//}
//#define EXPR(a) a
//void f() {
// switch (EXPR(1)) {
// default:
// break;
// }
//}
public void testMacroInSwitch() throws Exception {
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, CCorePlugin.SPACE);
assertFormatterResult();
}
//#define IF(cond) if(cond){}
//void f() { if(1){}IF(1>0);}