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
						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")) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user