Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergey Prigogin2011-09-21 00:28:53 +0000
committerSergey Prigogin2011-09-21 00:39:06 +0000
commite2aef245cdc7dd73235d035ba5b18ee41496ef1e (patch)
treebf6c05f61ccb9e157149d4805cd9657761d297ef
parentec3395e78d6f54c1167dc8adb8ace08f119a0fe2 (diff)
downloadorg.eclipse.cdt-e2aef245cdc7dd73235d035ba5b18ee41496ef1e.tar.gz
org.eclipse.cdt-e2aef245cdc7dd73235d035ba5b18ee41496ef1e.tar.xz
org.eclipse.cdt-e2aef245cdc7dd73235d035ba5b18ee41496ef1e.zip
Bug 357423. Fixed regression.
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java4
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java17
2 files changed, 19 insertions, 2 deletions
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java
index 765cf5c7e5..8cc1eb756e 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java
@@ -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);
}
/*
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java
index 8350569934..35feb483ca 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java
@@ -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);}

Back to the top