MCPcopy Create free account
hub / github.com/KDE/kdevelop / processCodeModel

Method processCodeModel

plugins/cmake/cmakeserverimportjob.cpp:24–99  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22#include "debug.h"
23
24void CMakeServerImportJob::processCodeModel(const QJsonObject &response, CMakeProjectData &data)
25{
26 const auto configs = response.value(QStringLiteral("configurations")).toArray();
27 qCDebug(CMAKE) << "process response" << response;
28
29 data.targets.clear();
30 data.compilationData.files.clear();
31
32 StringInterner stringInterner;
33
34 const auto rt = KDevelop::ICore::self()->runtimeController()->currentRuntime();
35 for (const auto &config: configs) {
36 const auto projects = config.toObject().value(QStringLiteral("projects")).toArray();
37 for (const auto &project: projects) {
38 const auto targets = project.toObject().value(QStringLiteral("targets")).toArray();
39 for (const auto &targetObject: targets) {
40 const auto target = targetObject.toObject();
41 const KDevelop::Path targetDir = rt->pathInHost(KDevelop::Path(target.value(QStringLiteral("sourceDirectory")).toString()));
42
43 KDevelop::Path::List targetSources;
44 const auto fileGroups = target.value(QStringLiteral("fileGroups")).toArray();
45 for (const auto &fileGroupValue: fileGroups) {
46 const auto fileGroup = fileGroupValue.toObject();
47 CMakeFile file;
48 file.includes = kTransform<KDevelop::Path::List>(fileGroup.value(QStringLiteral("includePath")).toArray(), [](const QJsonValue& val) { return KDevelop::Path(val.toObject().value(QStringLiteral("path")).toString()); });
49
50 file.language = fileGroup.value(QStringLiteral("language")).toString(),
51 file.compileFlags = fileGroup.value(QStringLiteral("compileFlags")).toString();
52 for (const auto& jsonDefine : fileGroup.value(QStringLiteral("defines")).toArray()) {
53 file.addDefine(jsonDefine.toString());
54 }
55 file.defines = MakeFileResolver::extractDefinesFromCompileFlags(file.compileFlags, stringInterner, file.defines);
56
57 // apparently some file groups do not contain build system information
58 // skip these, as they would produce bogus results for us and break the fallback
59 // implemented in CMakeManager::fileInformation
60 if (file.isEmpty()) {
61 continue;
62 }
63
64 const auto sourcesArray = fileGroup.value(QStringLiteral("sources")).toArray();
65 const KDevelop::Path::List sources = kTransform<KDevelop::Path::List>(sourcesArray, [targetDir](const QJsonValue& val) { return KDevelop::Path(targetDir, val.toString()); });
66 targetSources.reserve(targetSources.size() + sources.size());
67 for (const auto& source: sources) {
68 // NOTE: we use the canonical file path to prevent issues with symlinks in the path
69 // leading to lookup failures
70 const auto localFile = rt->pathInHost(source);
71 const auto canonicalFile = QFileInfo(source.toLocalFile()).canonicalFilePath();
72 const auto sourcePath = (canonicalFile.isEmpty() || localFile.toLocalFile() == canonicalFile)
73 ? localFile : KDevelop::Path(canonicalFile);
74 data.compilationData.files[sourcePath] = file;
75 targetSources << sourcePath;
76 }
77 qCDebug(CMAKE) << "registering..." << sources << file;
78 }
79
80 CMakeTarget cmakeTarget{
81 CMakeTarget::typeToEnum(target.value(QLatin1String("type")).toString()),

Callers

nothing calls this directly

Calls 15

currentRuntimeMethod · 0.80
runtimeControllerMethod · 0.80
addDefineMethod · 0.80
toLocalFileMethod · 0.80
PathClass · 0.70
QStringClass · 0.70
QFileInfoClass · 0.50
valueMethod · 0.45
clearMethod · 0.45
pathInHostMethod · 0.45
toStringMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected