forked from qt-creator/qt-creator
CppTools: Match also function arguments in locator
Useful when there are several overloads for the same function. Change-Id: I325bda7d2fdf4108f71a61d5473cd55310c51c28 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
committed by
Orgad Shaneh
parent
2d5d62fdbc
commit
bacfc28a36
@@ -83,8 +83,11 @@ QList<Core::LocatorFilterEntry> CppLocatorFilter::matchesFor(
|
||||
m_data->filterAllFiles([&](const IndexItem::Ptr &info) -> IndexItem::VisitorResult {
|
||||
if (future.isCanceled())
|
||||
return IndexItem::Break;
|
||||
if (info->type() & wanted) {
|
||||
const IndexItem::ItemType type = info->type();
|
||||
if (type & wanted) {
|
||||
QString matchString = hasColonColon ? info->scopedSymbolName() : info->symbolName();
|
||||
if (type == IndexItem::Function)
|
||||
matchString += info->symbolType();
|
||||
QRegularExpressionMatch match = regexp.match(matchString);
|
||||
if (match.hasMatch()) {
|
||||
Core::LocatorFilterEntry filterEntry = filterEntryFromIndexItem(info);
|
||||
|
||||
@@ -196,10 +196,26 @@ void CppToolsPlugin::test_cpplocatorfilters_CppLocatorFilter_data()
|
||||
<< _("pos")
|
||||
<< (QList<ResultData>()
|
||||
<< ResultData(_("positiveNumber()"), testFileShort)
|
||||
<< ResultData(_("getPosition()"), testFileShort)
|
||||
<< ResultData(_("matchArgument(Pos)"), testFileShort)
|
||||
<< ResultData(_("pointOfService()"), testFileShort)
|
||||
);
|
||||
|
||||
QTest::newRow("CppFunctionsFilter-arguments")
|
||||
<< testFile
|
||||
<< cppFunctionsFilter
|
||||
<< _("function*bool")
|
||||
<< (QList<ResultData>()
|
||||
<< ResultData(_("functionDefinedInClass(bool, int)"),
|
||||
_("MyClass (file1.cpp)"))
|
||||
<< ResultData(_("functionDefinedInClass(bool, int)"),
|
||||
_("MyNamespace::MyClass (file1.cpp)"))
|
||||
<< ResultData(_("functionDefinedInClass(bool, int)"),
|
||||
_("<anonymous namespace>::MyClass (file1.cpp)"))
|
||||
<< ResultData(_("myFunction(bool, int)"), testFileShort)
|
||||
<< ResultData(_("myFunction(bool, int)"), _("MyNamespace (file1.cpp)"))
|
||||
<< ResultData(_("myFunction(bool, int)"), _("<anonymous namespace> (file1.cpp)"))
|
||||
);
|
||||
|
||||
QTest::newRow("CppFunctionsFilter-WithNamespacePrefix")
|
||||
<< testFile
|
||||
<< cppFunctionsFilter
|
||||
@@ -290,8 +306,9 @@ void CppToolsPlugin::test_cpplocatorfilters_CppCurrentDocumentFilter()
|
||||
QList<ResultData> expectedResults = QList<ResultData>()
|
||||
<< ResultData(_("int myVariable"), _(""))
|
||||
<< ResultData(_("myFunction(bool, int)"), _(""))
|
||||
<< ResultData(_("Pos"), _(""))
|
||||
<< ResultData(_("pointOfService()"), _(""))
|
||||
<< ResultData(_("getPosition()"), _(""))
|
||||
<< ResultData(_("matchArgument(Pos)"), _(""))
|
||||
<< ResultData(_("positiveNumber()"), _(""))
|
||||
<< ResultData(_("MyEnum"), _(""))
|
||||
<< ResultData(_("int V1"), _("MyEnum"))
|
||||
|
||||
@@ -12,8 +12,9 @@ int myVariable;
|
||||
|
||||
int myFunction(bool yesno, int number) {}
|
||||
|
||||
struct Pos {};
|
||||
void pointOfService() {}
|
||||
int getPosition() { return 0; }
|
||||
int matchArgument(Pos p) { return 0; }
|
||||
int positiveNumber() { return 2; }
|
||||
|
||||
enum MyEnum { V1, V2 };
|
||||
|
||||
Reference in New Issue
Block a user