From 2e91dd1f3dcaf5912e386ed373f37c903058fea9 Mon Sep 17 00:00:00 2001 From: Nikolai Kosjar Date: Tue, 27 May 2014 09:25:29 -0400 Subject: [PATCH] C++: Fix matching NamedType NamedType::isEqualTo() wasn't properly moved to Matcher. In the test case, the function argument matching was failing. Change-Id: Ia3cb82c11b039ddea61a41d9574f56d43da16ed0 Reviewed-by: Erik Verbruggen --- src/libs/3rdparty/cplusplus/Matcher.cpp | 10 +++++++++- .../followsymbol_switchmethoddecldef_test.cpp | 10 ++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/libs/3rdparty/cplusplus/Matcher.cpp b/src/libs/3rdparty/cplusplus/Matcher.cpp index 518664b3be3..d4963b8892d 100644 --- a/src/libs/3rdparty/cplusplus/Matcher.cpp +++ b/src/libs/3rdparty/cplusplus/Matcher.cpp @@ -159,7 +159,15 @@ bool Matcher::match(const NamedType *type, const NamedType *otherType) if (type == otherType) return true; - else if (! Matcher::match(type->name(), otherType->name(), this)) + const Name *name = type->name(); + if (const QualifiedNameId *q = name->asQualifiedNameId()) + name = q->name(); + + const Name *otherName = otherType->name(); + if (const QualifiedNameId *q = otherName->asQualifiedNameId()) + otherName = q->name(); + + if (! Matcher::match(name, otherName, this)) return false; return true; diff --git a/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp b/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp index 1b203619252..3477e36f526 100644 --- a/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp +++ b/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp @@ -962,6 +962,16 @@ void CppEditorPlugin::test_FollowSymbolUnderCursor_multipleDocuments_data() "void Foo::$foo(int) {}\n", "foo.cpp") ); + + QTest::newRow("matchFunctionSignature2") << (QList() + << TestDocument::create("namespace N { class C; }\n" + "bool *@fun(N::C *) const;\n", + "foo.h") + << TestDocument::create("#include \"foo.h\"\n" + "using namespace N;\n" + "bool *$fun(C *) const {}\n", + "foo.cpp") + ); } void CppEditorPlugin::test_FollowSymbolUnderCursor_multipleDocuments()