From f73fa36c10642a5b4eddc2de6fb524a9c458d29d Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Mon, 26 Sep 2011 20:02:35 -0700 Subject: [PATCH] Tightened a test case and fixed an uncovered bug. --- .../cdt/internal/formatter/CodeFormatterVisitor.java | 4 +++- .../ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java | 6 ++++-- 2 files changed, 7 insertions(+), 3 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 c11b9330715..2368c0aee5c 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 @@ -918,8 +918,10 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor, */ @Override public int visit(IASTStatement node) { - if (startsWithMacroExpansion(node)) + if (scribe.scanner.getCurrentPosition() <= node.getFileLocation().getNodeOffset() && + startsWithMacroExpansion(node)) { scribe.printCommentPreservingNewLines(); + } if (!startNode(node)) { return PROCESS_SKIP; } int indentLevel= scribe.indentationLevel; try { 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 c8465829e89..989fa1fac6c 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 @@ -2472,8 +2472,10 @@ public class CodeFormatterTest extends BaseUITestCase { //#define MY_MACRO switch (0) case 0: default: if (bool x = false) ; else GetStream() // //void test() { - //MY_MACRO << "Loooooooooooooooooooong string literal" << " another literal."; - //MY_MACRO << "Looooooooooooooooooooong string literal" << " another literal."; + //MY_MACRO + //<< "Loooooooooooooooooooong string literal" << " another literal."; + //MY_MACRO + //<< "Looooooooooooooooooooong string literal" << " another literal."; //} //struct Stream {