AutoTest: Find data tags of inherited functions

Task-number: QTCREATORBUG-17522
Change-Id: I9fa1db3c2d7f338afe343fc835b9e3dbae353131
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Stenger
2017-01-04 15:47:46 +01:00
parent 0ceea628b0
commit 572b04a00a

View File

@@ -195,6 +195,23 @@ static QMap<QString, QtTestCodeLocationAndType> baseClassTestFunctions(const QSe
return testFunctions; return testFunctions;
} }
static QtTestCodeLocationList tagLocationsFor(const QtTestParseResult *func,
const QMap<QString, QtTestCodeLocationList> &dataTags)
{
if (!func->inherited())
return dataTags.value(func->name);
QMap<QString, QtTestCodeLocationList>::ConstIterator it = dataTags.begin();
QMap<QString, QtTestCodeLocationList>::ConstIterator end = dataTags.end();
const int lastColon = func->name.lastIndexOf(':');
QString funcName = lastColon == -1 ? func->name : func->name.mid(lastColon - 1);
for ( ; it != end; ++it) {
if (it.key().endsWith(funcName))
return it.value();
}
return QtTestCodeLocationList();
}
static bool handleQtTest(QFutureInterface<TestParseResultPtr> futureInterface, static bool handleQtTest(QFutureInterface<TestParseResultPtr> futureInterface,
CPlusPlus::Document::Ptr document, CPlusPlus::Document::Ptr document,
const CPlusPlus::Snapshot &snapshot, const CPlusPlus::Snapshot &snapshot,
@@ -255,7 +272,8 @@ static bool handleQtTest(QFutureInterface<TestParseResultPtr> futureInterface,
func->column = location.m_column; func->column = location.m_column;
func->setInherited(location.m_inherited); func->setInherited(location.m_inherited);
foreach (const QtTestCodeLocationAndType &tag, dataTags.value(func->name)) { const QtTestCodeLocationList &tagLocations = tagLocationsFor(func, dataTags);
foreach (const QtTestCodeLocationAndType &tag, tagLocations) {
QtTestParseResult *dataTag = new QtTestParseResult(id); QtTestParseResult *dataTag = new QtTestParseResult(id);
dataTag->itemType = tag.m_type; dataTag->itemType = tag.m_type;
dataTag->name = tag.m_name; dataTag->name = tag.m_name;