forked from qt-creator/qt-creator
Convert macros from plain QByteArray to a vector of structs
The old code model expected the macros as C++ formatted text
("#define Foo 42) but newer targets like the Clang codemodel expect key
value arguments like "-DFoo=42". So instead of parsing the text again and
again we use an abstract data description.
Task-number: QTCREATORBUG-17915
Change-Id: I0179fd13c48a581e91ee79bba9d42d501c26f19f
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -89,20 +89,21 @@ static bool includesQtQuickTest(const CPlusPlus::Document::Ptr &doc,
|
||||
static QString quickTestSrcDir(const CppTools::CppModelManager *cppMM,
|
||||
const QString &fileName)
|
||||
{
|
||||
static const QByteArray qtsd(" QUICK_TEST_SOURCE_DIR ");
|
||||
const QList<CppTools::ProjectPart::Ptr> parts = cppMM->projectPart(fileName);
|
||||
if (parts.size() > 0) {
|
||||
QByteArray projDefines(parts.at(0)->projectDefines);
|
||||
for (const QByteArray &line : projDefines.split('\n')) {
|
||||
if (line.contains(qtsd)) {
|
||||
QByteArray result = line.mid(line.indexOf(qtsd) + qtsd.length());
|
||||
if (result.startsWith('"'))
|
||||
result.remove(result.length() - 1, 1).remove(0, 1);
|
||||
if (result.startsWith("\\\""))
|
||||
result.remove(result.length() - 2, 2).remove(0, 2);
|
||||
return QLatin1String(result);
|
||||
}
|
||||
}
|
||||
const ProjectExplorer::Macros ¯os = parts.at(0)->projectMacros;
|
||||
auto found = std::find_if(
|
||||
macros.begin(),
|
||||
macros.end(),
|
||||
[] (const ProjectExplorer::Macro ¯o) { return macro.key == "QUICK_TEST_SOURCE_DIR"; });
|
||||
if (found != macros.end()) {
|
||||
QByteArray result = found->value;
|
||||
if (result.startsWith('"'))
|
||||
result.remove(result.length() - 1, 1).remove(0, 1);
|
||||
if (result.startsWith("\\\""))
|
||||
result.remove(result.length() - 2, 2).remove(0, 2);
|
||||
return QLatin1String(result);
|
||||
}
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user