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:
parent
ec3395e78d
commit
e2aef245cd
2 changed files with 19 additions and 2 deletions
|
@ -3526,14 +3526,14 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
|
||||||
* Controller expression
|
* Controller expression
|
||||||
*/
|
*/
|
||||||
IASTExpression controllerExpression = node.getControllerExpression();
|
IASTExpression controllerExpression = node.getControllerExpression();
|
||||||
if (!enclosedInMacroExpansion(controllerExpression)) {
|
if (!doNodesHaveSameOffset(node, controllerExpression)) {
|
||||||
scribe.printNextToken(Token.tLPAREN, preferences.insert_space_before_opening_paren_in_switch);
|
scribe.printNextToken(Token.tLPAREN, preferences.insert_space_before_opening_paren_in_switch);
|
||||||
if (preferences.insert_space_after_opening_paren_in_switch) {
|
if (preferences.insert_space_after_opening_paren_in_switch) {
|
||||||
scribe.space();
|
scribe.space();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
controllerExpression.accept(this);
|
controllerExpression.accept(this);
|
||||||
if (!enclosedInMacroExpansion(controllerExpression)) {
|
if (peekNextToken() == Token.tRPAREN) {
|
||||||
scribe.printNextToken(Token.tRPAREN, preferences.insert_space_before_closing_paren_in_switch);
|
scribe.printNextToken(Token.tRPAREN, preferences.insert_space_before_closing_paren_in_switch);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -2658,6 +2658,23 @@ public class CodeFormatterTest extends BaseUITestCase {
|
||||||
assertFormatterResult();
|
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){}
|
//#define IF(cond) if(cond){}
|
||||||
//void f() { if(1){}IF(1>0);}
|
//void f() { if(1){}IF(1>0);}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue