Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Stornelli2019-04-12 13:04:14 -0400
committerMarco Stornelli2019-05-08 01:20:23 -0400
commitbf0b7a76edd9cf4f3ea7b4a4adaff277fe03295a (patch)
tree19eefd3a5f4f9233b9c0b6f76f49ea80d002b913 /core/org.eclipse.cdt.core
parent838a12d8f4cca53657cb3e62fe2dfff2e4d50c6c (diff)
downloadorg.eclipse.cdt-bf0b7a76edd9cf4f3ea7b4a4adaff277fe03295a.tar.gz
org.eclipse.cdt-bf0b7a76edd9cf4f3ea7b4a4adaff277fe03295a.tar.xz
org.eclipse.cdt-bf0b7a76edd9cf4f3ea7b4a4adaff277fe03295a.zip
Bug 546221 - Fix exception for nested namespaces
Change-Id: I6de8844a910350a0e834a8f38e1c17d4eba32842 Signed-off-by: Marco Stornelli <marco.stornelli@gmail.com>
Diffstat (limited to 'core/org.eclipse.cdt.core')
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java15
1 files changed, 11 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 57cbe88923..89815c3e5e 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

Back to the top