2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2020 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2020-07-22 14:52:06 +02:00
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "clangfileinfo.h"
|
2020-08-25 06:18:26 +02:00
|
|
|
#include "clangtoolsdiagnostic.h"
|
2020-10-01 14:39:21 +02:00
|
|
|
#include "clangtoolsprojectsettings.h"
|
2020-07-22 14:52:06 +02:00
|
|
|
|
|
|
|
|
#include <utils/fileutils.h>
|
|
|
|
|
#include <utils/temporarydirectory.h>
|
|
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
|
#include <QTimer>
|
|
|
|
|
|
|
|
|
|
namespace Core { class IDocument; }
|
2021-08-30 10:58:08 +02:00
|
|
|
namespace CppEditor { class ClangDiagnosticConfig; }
|
2020-08-25 06:18:26 +02:00
|
|
|
namespace TextEditor { class TextEditorWidget; }
|
2020-07-22 14:52:06 +02:00
|
|
|
|
|
|
|
|
namespace ClangTools {
|
|
|
|
|
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
class ClangToolRunner;
|
|
|
|
|
class DiagnosticMark;
|
|
|
|
|
|
|
|
|
|
class DocumentClangToolRunner : public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
|
|
|
|
DocumentClangToolRunner(Core::IDocument *doc);
|
|
|
|
|
~DocumentClangToolRunner();
|
|
|
|
|
|
2020-08-25 06:18:26 +02:00
|
|
|
Utils::FilePath filePath() const;
|
|
|
|
|
Diagnostics diagnosticsAtLine(int lineNumber) const;
|
|
|
|
|
|
2020-07-22 14:52:06 +02:00
|
|
|
private:
|
|
|
|
|
void scheduleRun();
|
|
|
|
|
void run();
|
|
|
|
|
void runNext();
|
|
|
|
|
|
|
|
|
|
void onSuccess();
|
|
|
|
|
void onFailure(const QString &errorMessage, const QString &errorDetails);
|
|
|
|
|
|
|
|
|
|
void finalize();
|
|
|
|
|
|
|
|
|
|
void cancel();
|
|
|
|
|
|
2020-10-01 14:39:21 +02:00
|
|
|
bool isSuppressed(const Diagnostic &diagnostic) const;
|
2020-08-25 06:18:26 +02:00
|
|
|
|
2021-08-30 10:58:08 +02:00
|
|
|
const CppEditor::ClangDiagnosticConfig getDiagnosticConfig(ProjectExplorer::Project *project);
|
2020-07-22 14:52:06 +02:00
|
|
|
template<class T>
|
2021-08-30 10:58:08 +02:00
|
|
|
ClangToolRunner *createRunner(const CppEditor::ClangDiagnosticConfig &config,
|
2020-07-22 14:52:06 +02:00
|
|
|
const Utils::Environment &env);
|
|
|
|
|
|
|
|
|
|
QTimer m_runTimer;
|
|
|
|
|
Core::IDocument *m_document = nullptr;
|
|
|
|
|
Utils::TemporaryDirectory m_temporaryDir;
|
|
|
|
|
std::unique_ptr<ClangToolRunner> m_currentRunner;
|
|
|
|
|
QList<std::function<ClangToolRunner *()>> m_runnerCreators;
|
|
|
|
|
QList<DiagnosticMark *> m_marks;
|
|
|
|
|
FileInfo m_fileInfo;
|
|
|
|
|
QMetaObject::Connection m_projectSettingsUpdate;
|
2020-11-25 14:54:19 +01:00
|
|
|
QList<QPointer<TextEditor::TextEditorWidget>> m_editorsWithMarkers;
|
2020-10-01 14:39:21 +02:00
|
|
|
SuppressedDiagnosticsList m_suppressed;
|
|
|
|
|
Utils::FilePath m_lastProjectDirectory;
|
2020-07-22 14:52:06 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace ClangTools
|