mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 17:56:01 +02:00
Bug532849 Inline namespace not recognized by formatter
Change-Id: Ie7f13884967685fcc93c8af3955d90825d6f9879 Signed-off-by: Hansruedi Patzen <hansruedi.patzen@hsr.ch> Signed-off-by: Thomas Corbat <tcorbat@hsr.ch>
This commit is contained in:
parent
cf25db1d34
commit
7b53e75fb2
4 changed files with 30 additions and 0 deletions
|
@ -164,3 +164,11 @@ int main()
|
||||||
//%CPP
|
//%CPP
|
||||||
static_assert(true, "Should always pass");
|
static_assert(true, "Should always pass");
|
||||||
static_assert(sizeof (int) == 4);
|
static_assert(sizeof (int) == 4);
|
||||||
|
|
||||||
|
//!Inline namespace
|
||||||
|
//%CPP
|
||||||
|
inline namespace InlnNS
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -203,6 +203,9 @@ public class DeclarationWriter extends NodeWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeNamespaceDefinition(ICPPASTNamespaceDefinition namespaceDefinition) {
|
private void writeNamespaceDefinition(ICPPASTNamespaceDefinition namespaceDefinition) {
|
||||||
|
if (namespaceDefinition.isInline()) {
|
||||||
|
scribe.printStringSpace(Keywords.INLINE);
|
||||||
|
}
|
||||||
scribe.printStringSpace(Keywords.NAMESPACE);
|
scribe.printStringSpace(Keywords.NAMESPACE);
|
||||||
namespaceDefinition.getName().accept(visitor);
|
namespaceDefinition.getName().accept(visitor);
|
||||||
writeGCCAttributes(namespaceDefinition, EnumSet.of(SpaceLocation.BEFORE));
|
writeGCCAttributes(namespaceDefinition, EnumSet.of(SpaceLocation.BEFORE));
|
||||||
|
|
|
@ -1089,6 +1089,12 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
|
||||||
public int visit(ICPPASTNamespaceDefinition node) {
|
public int visit(ICPPASTNamespaceDefinition node) {
|
||||||
if (!enterNode(node)) { return PROCESS_SKIP; }
|
if (!enterNode(node)) { return PROCESS_SKIP; }
|
||||||
final int line= scribe.line;
|
final int line= scribe.line;
|
||||||
|
|
||||||
|
if (node.isInline()) {
|
||||||
|
scribe.printNextToken(Token.t_inline, false);
|
||||||
|
scribe.space();
|
||||||
|
}
|
||||||
|
|
||||||
// namespace <name>
|
// namespace <name>
|
||||||
scribe.printNextToken(Token.t_namespace, false);
|
scribe.printNextToken(Token.t_namespace, false);
|
||||||
scribe.space();
|
scribe.space();
|
||||||
|
|
|
@ -3371,4 +3371,17 @@ public class CodeFormatterTest extends BaseUITestCase {
|
||||||
public void testSwitchInitStatementFormat_4() throws Exception {
|
public void testSwitchInitStatementFormat_4() throws Exception {
|
||||||
assertFormatterResult();
|
assertFormatterResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//namespace na {
|
||||||
|
//inline namespace nb {
|
||||||
|
//}
|
||||||
|
//}
|
||||||
|
|
||||||
|
//namespace na {
|
||||||
|
//inline namespace nb {
|
||||||
|
//}
|
||||||
|
//}
|
||||||
|
public void testInlineNamespace_Bug532849() throws Exception {
|
||||||
|
assertFormatterResult();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue