CMake: Extract crossReferences data of targets in server-mode

Use the information to add a filenode below a target that takes
you directly to the target definition.

Change-Id: Ifcb8e2c4f085110033019ea3816c79f5b8630472
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Tobias Hunger
2017-07-04 15:49:29 +02:00
parent 7afae6b4fd
commit d8e0ecb0ab
2 changed files with 126 additions and 1 deletions

View File

@@ -29,6 +29,8 @@
#include "servermode.h"
#include "cmakeparser.h"
#include <QList>
#include <memory>
namespace CMakeProjectManager {
@@ -87,8 +89,26 @@ private:
bool isGenerated;
};
struct BacktraceItem {
int line = -1;
QString path;
QString name;
};
struct CrossReference {
~CrossReference() { qDeleteAll(backtrace); backtrace.clear(); }
QList<BacktraceItem *> backtrace;
enum Type { TARGET, LIBRARIES, DEFINES, INCLUDES, UNKNOWN };
Type type;
};
struct Target {
~Target() { qDeleteAll(fileGroups); fileGroups.clear(); }
~Target() {
qDeleteAll(fileGroups);
fileGroups.clear();
qDeleteAll(crossReferences);
crossReferences.clear();
}
Project *project = nullptr;
QString name;
@@ -97,6 +117,7 @@ private:
Utils::FileName sourceDirectory;
Utils::FileName buildDirectory;
QList<FileGroup *> fileGroups;
QList<CrossReference *> crossReferences;
};
struct Project {
@@ -111,6 +132,9 @@ private:
Project *extractProjectData(const QVariantMap &data, QSet<QString> &knownTargets);
Target *extractTargetData(const QVariantMap &data, Project *p, QSet<QString> &knownTargets);
FileGroup *extractFileGroupData(const QVariantMap &data, const QDir &srcDir, Target *t);
QList<CrossReference *> extractCrossReferences(const QVariantMap &data);
QList<BacktraceItem *> extractBacktrace(const QVariantList &data);
BacktraceItem *extractBacktraceItem(const QVariantMap &data);
void extractCMakeInputsData(const QVariantMap &data);
void extractCacheData(const QVariantMap &data);