1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-13 19:25:38 +02:00

Bug 546221 - Fix exception for nested namespaces

Change-Id: I6de8844a910350a0e834a8f38e1c17d4eba32842
Signed-off-by: Marco Stornelli <marco.stornelli@gmail.com>
This commit is contained in:
Marco Stornelli 2019-04-12 19:04:14 +02:00
parent 838a12d8f4
commit bf0b7a76ed
2 changed files with 21 additions and 4 deletions

View file

@ -1127,15 +1127,22 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
scribe.space();
}
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

View file

@ -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();
}
}