Skip to main content
summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMarco Stornelli2019-03-06 13:08:17 -0500
committerMarco Stornelli2019-03-06 13:08:17 -0500
commit3113871624d733abf81b4efd24cce957f25ef6c3 (patch)
treef69322f02167eea9cd06e7090a4032155264a9d2 /core
parentf28b158828d7c7e2d6b5219d31e676483d61b3b9 (diff)
downloadorg.eclipse.cdt-3113871624d733abf81b4efd24cce957f25ef6c3.tar.gz
org.eclipse.cdt-3113871624d733abf81b4efd24cce957f25ef6c3.tar.xz
org.eclipse.cdt-3113871624d733abf81b4efd24cce957f25ef6c3.zip
Bug 543947: Fix exception while formatting macro
Change-Id: If3e1a4da919c4e7f78ca4506e97ea1f6f37f7c8c Signed-off-by: Marco Stornelli <marco.stornelli@gmail.com>
Diffstat (limited to 'core')
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java3
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java30
2 files changed, 32 insertions, 1 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 cd502b3f7e..2129e9d44f 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
@@ -3556,7 +3556,8 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
}
for (ICPPASTNameSpecifier nameSpec : node.getQualifier()) {
nameSpec.accept(this);
- scribe.printNextToken(Token.tCOLONCOLON);
+ if (peekNextToken() == Token.tCOLONCOLON)
+ scribe.printNextToken(Token.tCOLONCOLON);
}
if (peekNextToken() == Token.tCOMPL) {
// destructor
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 ec166d5bfa..8f13333597 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
@@ -3781,4 +3781,34 @@ public class CodeFormatterTest extends BaseUITestCase {
public void testTemplateInstantiationOperatorLesser_Bug540252() throws Exception {
assertFormatterResult();
}
+
+ //#define WW(x) std::ostringstream(x)
+ //namespace some_namespace
+ //{
+ // void func()
+ // {
+ // try
+ // {
+ // WW("1") << "2";
+ // }
+ // catch (const std::exception& e)
+ // {
+ // std::cout << "blah...." << std::endl;
+ // }
+ // }
+ //}
+
+ //#define WW(x) std::ostringstream(x)
+ //namespace some_namespace {
+ //void func() {
+ // try {
+ // WW("1") << "2";
+ // } catch (const std::exception& e) {
+ // std::cout << "blah...." << std::endl;
+ // }
+ //}
+ //}
+ public void testFormmatterWithMacro_Bug543947() throws Exception {
+ assertFormatterResult();
+ }
}

Back to the top