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 ec4120f1d3a..796b7bd8f1c 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 @@ -1295,9 +1295,6 @@ public class CodeFormatterVisitor extends CPPASTVisitor { private int visit(IASTIdExpression node) { node.getName().accept(this); - if (scribe.printComment()) { - scribe.space(); - } return PROCESS_SKIP; } @@ -1453,6 +1450,9 @@ public class CodeFormatterVisitor extends CPPASTVisitor { break; case IASTUnaryExpression.op_sizeof: scribe.printNextToken(Token.t_sizeof, scribe.printComment()); + if (peekNextToken() != Token.tLPAREN) { + scribe.space(); + } operand.accept(this); break; default: @@ -1487,7 +1487,6 @@ public class CodeFormatterVisitor extends CPPASTVisitor { // operand 2 final IASTExpression op2= node.getOperand2(); op2.accept(this); - scribe.printTrailingComment(); ok = true; } catch (AlignmentException e) { 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 f5e758bb498..6747e599491 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 @@ -141,6 +141,15 @@ public class CodeFormatterTest extends BaseUITestCase { assertFormatterResult(); } + //int x; + //int a = sizeof x ; + + //int x; + //int a = sizeof x; + public void testSizeofExpression_Bug201330() throws Exception { + assertFormatterResult(); + } + //void foo(){ //for(;;){ //int a=0;