2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2019 The Qt Company Ltd.
|
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
2019-05-16 15:36:55 +02:00
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "compilationdatabaseutils.h"
|
|
|
|
|
|
2019-10-25 09:55:32 +02:00
|
|
|
#include <projectexplorer/buildsystem.h>
|
2019-08-06 14:46:37 +02:00
|
|
|
|
2019-05-16 15:36:55 +02:00
|
|
|
#include <utils/fileutils.h>
|
|
|
|
|
|
|
|
|
|
#include <QFutureWatcher>
|
|
|
|
|
#include <QList>
|
|
|
|
|
#include <QObject>
|
|
|
|
|
#include <QStringList>
|
|
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
namespace ProjectExplorer {
|
|
|
|
|
class FileNode;
|
|
|
|
|
class TreeScanner;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
namespace CompilationDatabaseProjectManager {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2019-10-22 09:43:24 +02:00
|
|
|
enum class ParseResult { Success, Failure, Cached };
|
|
|
|
|
|
2019-05-16 15:36:55 +02:00
|
|
|
class CompilationDbParser : public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
2019-08-06 14:46:37 +02:00
|
|
|
explicit CompilationDbParser(const QString &projectName,
|
|
|
|
|
const Utils::FilePath &projectPath,
|
|
|
|
|
const Utils::FilePath &rootPath,
|
|
|
|
|
MimeBinaryCache &mimeBinaryCache,
|
2019-10-25 09:55:32 +02:00
|
|
|
ProjectExplorer::BuildSystem::ParseGuard &&guard,
|
2019-05-16 15:36:55 +02:00
|
|
|
QObject *parent = nullptr);
|
|
|
|
|
|
2019-10-22 09:43:24 +02:00
|
|
|
|
|
|
|
|
void setPreviousProjectFileHash(const QByteArray &fileHash) { m_projectFileHash = fileHash; }
|
|
|
|
|
QByteArray projectFileHash() const { return m_projectFileHash; }
|
|
|
|
|
|
2019-05-16 15:36:55 +02:00
|
|
|
void start();
|
|
|
|
|
void stop();
|
|
|
|
|
|
|
|
|
|
QList<ProjectExplorer::FileNode *> scannedFiles() const;
|
2019-08-06 14:46:37 +02:00
|
|
|
DbContents dbContents() const
|
|
|
|
|
{
|
|
|
|
|
return m_dbContents;
|
|
|
|
|
}
|
2019-05-16 15:36:55 +02:00
|
|
|
|
|
|
|
|
signals:
|
2019-10-22 09:43:24 +02:00
|
|
|
void finished(ParseResult result);
|
2019-05-16 15:36:55 +02:00
|
|
|
|
|
|
|
|
private:
|
2021-09-15 16:32:11 +02:00
|
|
|
void parserJobFinished();
|
2019-10-22 09:43:24 +02:00
|
|
|
void finish(ParseResult result);
|
2019-05-16 15:36:55 +02:00
|
|
|
DbContents parseProject();
|
2019-10-22 09:43:24 +02:00
|
|
|
std::vector<DbEntry> readJsonObjects() const;
|
2019-05-16 15:36:55 +02:00
|
|
|
|
|
|
|
|
const QString m_projectName;
|
2019-05-28 13:49:26 +02:00
|
|
|
const Utils::FilePath m_projectFilePath;
|
|
|
|
|
const Utils::FilePath m_rootPath;
|
2019-05-16 15:36:55 +02:00
|
|
|
MimeBinaryCache &m_mimeBinaryCache;
|
|
|
|
|
ProjectExplorer::TreeScanner *m_treeScanner = nullptr;
|
|
|
|
|
QFutureWatcher<DbContents> m_parserWatcher;
|
|
|
|
|
DbContents m_dbContents;
|
2019-10-22 09:43:24 +02:00
|
|
|
QByteArray m_projectFileContents;
|
|
|
|
|
QByteArray m_projectFileHash;
|
2021-09-15 16:32:11 +02:00
|
|
|
int m_runningParserJobs = 0;
|
2019-08-06 14:46:37 +02:00
|
|
|
|
2019-10-25 09:55:32 +02:00
|
|
|
ProjectExplorer::BuildSystem::ParseGuard m_guard;
|
2019-05-16 15:36:55 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace CompilationDatabaseProjectManager
|