Commit 2da988ae authored by Milian Wolff's avatar Milian Wolff

CMake: skip server entries without empty build system information

Summary:
In one of my work projects, the CMake 3.13.1 server gave fileGroups
responses without any useful CMakeFile data. This then was stored
in our lookup hash used by CMakeManager::fileInformation.

Then later, when we queried for these files, we found a match,
albeit empty, and returned that leading to completely broken C++
language support.

To prevent this issue, we now skip useless empty CMakeFile entries.
This fixes the specific scenario I'm seeing in my work project.

Subscribers: kdevelop-devel

Tags: #kdevelop

Differential Revision: https://phabricator.kde.org/D17679
parent cc1a24f5
......@@ -41,6 +41,12 @@ struct CMakeFile
KDevelop::Path::List frameworkDirectories;
QString compileFlags;
QHash<QString, QString> defines;
bool isEmpty() const
{
return includes.isEmpty() && frameworkDirectories.isEmpty()
&& compileFlags.isEmpty() && defines.isEmpty();
}
};
inline QDebug &operator<<(QDebug debug, const CMakeFile& file)
{
......
......@@ -118,6 +118,13 @@ void CMakeServerImportJob::processCodeModel(const QJsonObject &response, CMakePr
file.compileFlags = fileGroup.value(QStringLiteral("compileFlags")).toString();
file.defines = processDefines(file.compileFlags, fileGroup.value(QStringLiteral("defines")).toArray());
// apparently some file groups do not contain build system information
// skip these, as they would produce bogus results for us and break the fallback
// implemented in CMakeManager::fileInformation
if (file.isEmpty()) {
continue;
}
const auto sourcesArray = fileGroup.value(QStringLiteral("sources")).toArray();
const KDevelop::Path::List sources = kTransform<KDevelop::Path::List>(sourcesArray, [targetDir](const QJsonValue& val) { return KDevelop::Path(targetDir, val.toString()); });
targetSources.reserve(targetSources.size() + sources.size());
......
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