Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java15
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java10
2 files changed, 21 insertions, 4 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 57cbe88923b..89815c3e5e4 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
@@ -1127,15 +1127,22 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
scribe.space();
}
- // namespace <name>
- scribe.printNextToken(Token.t_namespace, false);
- scribe.space();
- formatLeadingAttributes(node, ICPPASTAttributeList.TYPE_FILTER);
+ if (peekNextToken() == Token.tCOLONCOLON) {
+ // namespace <name>::<name>
+ scribe.printNextToken(Token.tCOLONCOLON, false);
+ } else {
+ // namespace <name>
+ scribe.printNextToken(Token.t_namespace, false);
+ scribe.space();
+ formatLeadingAttributes(node, ICPPASTAttributeList.TYPE_FILTER);
+ }
boolean isNamedNamespace = !CPPVisitor.isAnonymousNamespace(node);
if (isNamedNamespace) {
IASTName name = node.getName();
name.accept(this);
}
+ if (peekNextToken() == Token.tCOLONCOLON)
+ return PROCESS_CONTINUE;
formatAttributes(node, isNamedNamespace, false, IGCCASTAttributeList.TYPE_FILTER);
// member declarations
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 e73ffa8a746..6e73fea3322 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
@@ -4081,6 +4081,16 @@ public class CodeFormatterTest extends BaseUITestCase {
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_USE_COMMENT_TAG, true);
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_ON_TAG, "@formatter:on");
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_OFF_TAG, "@formatter:off");
+ }
+
+ //namespace AA::BB {
+ //int a;
+ //}
+
+ //namespace AA::BB {
+ //int a;
+ //}
+ public void testNestedNamespace_Bug546221() throws Exception {
assertFormatterResult();
}
}

Back to the top