Commit b41346cf authored by Christian Kandeler's avatar Christian Kandeler

CppTools: Add file path to extra info in function Locator filter.

This helps tremendously in the not uncommon case of the same class being
implemented in several files (e.g. for different operating systems).
Until now, users would be completely at a loss as to which of the
results was the one they were interested in.

Change-Id: I3ef8c8dc93b89e68eaf323a7ad2067b075d8cfb1
Task-number: QTCREATORBUG-11125
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <orgads@gmail.com>
parent b967e2c2
......@@ -25,6 +25,8 @@
#include "cppfunctionsfilter.h"
#include <utils/fileutils.h>
using namespace CppTools;
using namespace CppTools::Internal;
......@@ -48,8 +50,13 @@ Core::LocatorFilterEntry CppFunctionsFilter::filterEntryFromIndexItem(IndexItem:
QString name = info->symbolName();
QString extraInfo = info->symbolScope();
info->unqualifiedNameAndScope(name, &name, &extraInfo);
if (extraInfo.isEmpty())
if (extraInfo.isEmpty()) {
extraInfo = info->shortNativeFilePath();
} else {
extraInfo.append(QLatin1String(" ("))
.append(Utils::FileName::fromString(info->fileName()).fileName())
.append(QLatin1String(")"));
}
Core::LocatorFilterEntry filterEntry(this, name + info->symbolType(), id, info->icon());
filterEntry.extraInfo = extraInfo;
......
......@@ -175,19 +175,21 @@ void CppToolsPlugin::test_cpplocatorfilters_CppLocatorFilter_data()
<< cppFunctionsFilter
<< _("function")
<< (QList<ResultData>()
<< ResultData(_("functionDefinedInClass(bool, int)"), _("MyClass"))
<< ResultData(_("functionDefinedInClass(bool, int)"), _("MyNamespace::MyClass"))
<< ResultData(_("functionDefinedInClass(bool, int)"), _("MyClass (file1.cpp)"))
<< ResultData(_("functionDefinedInClass(bool, int)"),
_("<anonymous namespace>::MyClass"))
<< ResultData(_("functionDefinedOutSideClass(char)"), _("MyClass"))
<< ResultData(_("functionDefinedOutSideClass(char)"), _("MyNamespace::MyClass"))
_("MyNamespace::MyClass (file1.cpp)"))
<< ResultData(_("functionDefinedInClass(bool, int)"),
_("<anonymous namespace>::MyClass (file1.cpp)"))
<< ResultData(_("functionDefinedOutSideClass(char)"), _("MyClass (file1.cpp)"))
<< ResultData(_("functionDefinedOutSideClass(char)"),
_("MyNamespace::MyClass (file1.cpp)"))
<< ResultData(_("functionDefinedOutSideClass(char)"),
_("<anonymous namespace>::MyClass"))
_("<anonymous namespace>::MyClass (file1.cpp)"))
<< ResultData(_("functionDefinedOutSideClassAndNamespace(float)"),
_("MyNamespace::MyClass"))
_("MyNamespace::MyClass (file1.cpp)"))
<< ResultData(_("myFunction(bool, int)"), testFileShort)
<< ResultData(_("myFunction(bool, int)"), _("MyNamespace"))
<< ResultData(_("myFunction(bool, int)"), _("<anonymous namespace>"))
<< ResultData(_("myFunction(bool, int)"), _("MyNamespace (file1.cpp)"))
<< ResultData(_("myFunction(bool, int)"), _("<anonymous namespace> (file1.cpp)"))
);
QTest::newRow("CppFunctionsFilter-WithNamespacePrefix")
......@@ -195,12 +197,14 @@ void CppToolsPlugin::test_cpplocatorfilters_CppLocatorFilter_data()
<< cppFunctionsFilter
<< _("mynamespace::")
<< (QList<ResultData>()
<< ResultData(_("MyClass()"), _("MyNamespace::MyClass"))
<< ResultData(_("functionDefinedInClass(bool, int)"), _("MyNamespace::MyClass"))
<< ResultData(_("functionDefinedOutSideClass(char)"), _("MyNamespace::MyClass"))
<< ResultData(_("MyClass()"), _("MyNamespace::MyClass (file1.cpp)"))
<< ResultData(_("functionDefinedInClass(bool, int)"),
_("MyNamespace::MyClass (file1.cpp)"))
<< ResultData(_("functionDefinedOutSideClass(char)"),
_("MyNamespace::MyClass (file1.cpp)"))
<< ResultData(_("functionDefinedOutSideClassAndNamespace(float)"),
_("MyNamespace::MyClass"))
<< ResultData(_("myFunction(bool, int)"), _("MyNamespace"))
_("MyNamespace::MyClass (file1.cpp)"))
<< ResultData(_("myFunction(bool, int)"), _("MyNamespace (file1.cpp)"))
);
QTest::newRow("CppClassesFilter")
......@@ -264,9 +268,9 @@ void CppToolsPlugin::test_cpplocatorfilters_CppLocatorFilter_data()
<< cppFunctionsFilter
<< _("M")
<< (QList<ResultData>()
<< ResultData(_("anotherMethod"), _("MyClass"))
<< ResultData(_("anotherMethod:"), _("MyClass"))
<< ResultData(_("someMethod"), _("MyClass"))
<< ResultData(_("anotherMethod"), _("MyClass (file1.mm)"))
<< ResultData(_("anotherMethod:"), _("MyClass (file1.mm)"))
<< ResultData(_("someMethod"), _("MyClass (file1.mm)"))
);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment