diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/libs/cplusplus/LookupContext.cpp | 9 | ||||
-rw-r--r-- | src/plugins/cppeditor/quickfixes/insertfunctiondefinition.cpp | 24 |
2 files changed, 28 insertions, 5 deletions
diff --git a/src/libs/cplusplus/LookupContext.cpp b/src/libs/cplusplus/LookupContext.cpp index 4a25a873389..ec69b2ddf71 100644 --- a/src/libs/cplusplus/LookupContext.cpp +++ b/src/libs/cplusplus/LookupContext.cpp @@ -214,13 +214,12 @@ static bool symbolIdentical(Symbol *s1, Symbol *s2) static bool isInlineNamespace(ClassOrNamespace *con, const Name *name) { const QList<LookupItem> items = con->find(name); - if (!items.isEmpty()) { - if (const Symbol *declaration = items.first().declaration() ) { - if (const Namespace *ns = declaration->asNamespace()) - return ns->isInline(); + for (const LookupItem &item : items) { + if (const Symbol * const declaration = item.declaration()) { + if (const Namespace *ns = declaration->asNamespace(); ns && ns->isInline()) + return true; } } - return false; } diff --git a/src/plugins/cppeditor/quickfixes/insertfunctiondefinition.cpp b/src/plugins/cppeditor/quickfixes/insertfunctiondefinition.cpp index 24a2decc7af..eb3e8781001 100644 --- a/src/plugins/cppeditor/quickfixes/insertfunctiondefinition.cpp +++ b/src/plugins/cppeditor/quickfixes/insertfunctiondefinition.cpp @@ -2142,6 +2142,30 @@ foo::foo2::MyType<int> foo::foo2::bar() factory.setOutside(); QuickFixOperationTest(singleHeader(original, expected), &factory); } + + void testInlineNamespace() + { + QByteArray original = + "namespace A { inline namespace X {}}\n" + "namespace A { namespace B { namespace X { class Bar{}; }}}\n" + "class Foo\n" + "{\n" + " void fu@nc(A::B::Bar b);\n" + "};\n"; + QByteArray expected = + "namespace A { inline namespace X {}}\n" + "namespace A { namespace B { namespace X { class Bar{}; }}}\n" + "class Foo\n" + "{\n" + " void fu@nc(A::B::Bar b);\n" + "};\n\n" + "void Foo::func(A::B::Bar b)\n" + "{\n\n" + "}\n"; + + InsertDefFromDecl factory; + QuickFixOperationTest(singleDocument(original, expected), &factory); + } }; class InsertDefsFromDeclsTest : public QObject |