2013-12-10 14:37:32 +01:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2013-12-10 14:37:32 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator.
|
|
|
|
|
**
|
|
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2013-12-10 14:37:32 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2013-12-10 14:37:32 +01:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
2016-03-18 07:55:01 +01:00
|
|
|
#pragma once
|
2013-12-10 14:37:32 +01:00
|
|
|
|
2015-09-04 12:15:17 +02:00
|
|
|
#include "clangdiagnosticmanager.h"
|
2014-08-19 15:59:29 +02:00
|
|
|
#include "clangeditordocumentparser.h"
|
2013-12-10 14:37:32 +01:00
|
|
|
|
2014-08-19 15:59:29 +02:00
|
|
|
#include <cpptools/builtineditordocumentprocessor.h>
|
|
|
|
|
#include <cpptools/semantichighlighter.h>
|
2013-12-10 14:37:32 +01:00
|
|
|
|
2021-05-12 15:12:48 +02:00
|
|
|
#include <utils/futuresynchronizer.h>
|
2020-06-26 13:59:38 +02:00
|
|
|
#include <utils/id.h>
|
|
|
|
|
|
2014-08-19 15:59:29 +02:00
|
|
|
#include <QFutureWatcher>
|
2016-09-14 16:16:10 +02:00
|
|
|
#include <QTimer>
|
2013-12-10 14:37:32 +01:00
|
|
|
|
2015-08-31 16:28:26 +02:00
|
|
|
namespace ClangBackEnd {
|
|
|
|
|
class DiagnosticContainer;
|
2017-12-05 09:42:35 +01:00
|
|
|
class TokenInfoContainer;
|
2015-10-05 11:17:03 +02:00
|
|
|
class FileContainer;
|
2015-08-31 16:28:26 +02:00
|
|
|
}
|
|
|
|
|
|
2013-12-10 14:37:32 +01:00
|
|
|
namespace ClangCodeModel {
|
2015-05-08 15:48:17 +02:00
|
|
|
namespace Internal {
|
|
|
|
|
|
2017-09-25 15:10:48 +02:00
|
|
|
class BackendCommunicator;
|
2013-12-10 14:37:32 +01:00
|
|
|
|
2014-08-19 15:59:29 +02:00
|
|
|
class ClangEditorDocumentProcessor : public CppTools::BaseEditorDocumentProcessor
|
2013-12-10 14:37:32 +01:00
|
|
|
{
|
2014-08-19 15:59:29 +02:00
|
|
|
Q_OBJECT
|
2013-12-10 14:37:32 +01:00
|
|
|
|
2014-08-19 15:59:29 +02:00
|
|
|
public:
|
2017-09-25 15:10:48 +02:00
|
|
|
ClangEditorDocumentProcessor(BackendCommunicator &communicator,
|
2015-05-08 15:48:17 +02:00
|
|
|
TextEditor::TextDocument *document);
|
2018-01-19 14:11:01 +01:00
|
|
|
~ClangEditorDocumentProcessor() override;
|
2013-12-10 14:37:32 +01:00
|
|
|
|
2014-08-19 15:59:29 +02:00
|
|
|
// BaseEditorDocumentProcessor interface
|
2016-12-14 18:58:23 +01:00
|
|
|
void runImpl(const CppTools::BaseEditorDocumentParser::UpdateParams &updateParams) override;
|
2015-06-19 14:43:41 +02:00
|
|
|
void semanticRehighlight() override;
|
2015-06-19 14:37:26 +02:00
|
|
|
void recalculateSemanticInfoDetached(bool force) override;
|
2015-06-03 15:33:22 +02:00
|
|
|
CppTools::SemanticInfo recalculateSemanticInfo() override;
|
2015-09-01 17:34:07 +02:00
|
|
|
CppTools::BaseEditorDocumentParser::Ptr parser() override;
|
2015-06-03 15:33:22 +02:00
|
|
|
CPlusPlus::Snapshot snapshot() override;
|
|
|
|
|
bool isParserRunning() const override;
|
2013-12-10 14:37:32 +01:00
|
|
|
|
2015-09-28 15:15:25 +02:00
|
|
|
bool hasProjectPart() const;
|
2015-07-14 19:01:32 +02:00
|
|
|
CppTools::ProjectPart::Ptr projectPart() const;
|
2015-09-18 12:19:46 +02:00
|
|
|
void clearProjectPart();
|
2015-07-14 19:01:32 +02:00
|
|
|
|
2020-06-26 13:59:38 +02:00
|
|
|
::Utils::Id diagnosticConfigId() const;
|
2018-01-19 16:57:18 +01:00
|
|
|
|
2015-08-31 16:28:26 +02:00
|
|
|
void updateCodeWarnings(const QVector<ClangBackEnd::DiagnosticContainer> &diagnostics,
|
2016-10-04 16:23:42 +02:00
|
|
|
const ClangBackEnd::DiagnosticContainer &firstHeaderErrorDiagnostic,
|
2015-08-31 16:28:26 +02:00
|
|
|
uint documentRevision);
|
2017-12-05 09:42:35 +01:00
|
|
|
void updateHighlighting(const QVector<ClangBackEnd::TokenInfoContainer> &tokenInfos,
|
2015-11-18 17:07:44 +01:00
|
|
|
const QVector<ClangBackEnd::SourceRangeContainer> &skippedPreprocessorRanges,
|
|
|
|
|
uint documentRevision);
|
2018-01-19 09:18:57 +01:00
|
|
|
void updateTokenInfos(const QVector<ClangBackEnd::TokenInfoContainer> &tokenInfos,
|
|
|
|
|
uint documentRevision);
|
2015-08-31 16:28:26 +02:00
|
|
|
|
2015-08-24 18:26:09 +02:00
|
|
|
TextEditor::QuickFixOperations
|
|
|
|
|
extraRefactoringOperations(const TextEditor::AssistInterface &assistInterface) override;
|
|
|
|
|
|
2017-07-03 13:29:30 +02:00
|
|
|
void invalidateDiagnostics() override;
|
2019-01-31 13:16:44 +01:00
|
|
|
|
|
|
|
|
TextEditor::TextMarks diagnosticTextMarksAt(uint line, uint column) const;
|
2016-01-27 13:37:19 +01:00
|
|
|
|
2016-09-14 16:16:10 +02:00
|
|
|
void editorDocumentTimerRestarted() override;
|
|
|
|
|
|
2019-01-14 01:40:53 +01:00
|
|
|
void setParserConfig(const CppTools::BaseEditorDocumentParser::Configuration &config) override;
|
2017-01-18 15:05:46 +01:00
|
|
|
|
2017-05-24 13:23:01 +02:00
|
|
|
QFuture<CppTools::CursorInfo> cursorInfo(const CppTools::CursorInfoParams ¶ms) override;
|
2017-09-26 16:00:30 +02:00
|
|
|
QFuture<CppTools::CursorInfo> requestLocalReferences(const QTextCursor &cursor) override;
|
2017-09-08 09:33:35 +02:00
|
|
|
QFuture<CppTools::SymbolInfo> requestFollowSymbol(int line, int column) override;
|
2018-01-12 12:29:43 +01:00
|
|
|
QFuture<CppTools::ToolTipInfo> toolTipInfo(const QByteArray &codecName,
|
|
|
|
|
int line,
|
|
|
|
|
int column) override;
|
2017-05-24 13:23:01 +02:00
|
|
|
|
2018-05-31 15:21:53 +02:00
|
|
|
void closeBackendDocument();
|
2015-10-05 11:17:03 +02:00
|
|
|
|
2015-11-25 15:11:23 +01:00
|
|
|
void clearDiagnosticsWithFixIts();
|
|
|
|
|
|
2017-12-05 09:42:35 +01:00
|
|
|
const QVector<ClangBackEnd::TokenInfoContainer> &tokenInfos() const;
|
2017-09-08 09:33:35 +02:00
|
|
|
|
2018-04-20 13:55:49 +02:00
|
|
|
static void clearTaskHubIssues();
|
2018-04-12 14:49:07 +02:00
|
|
|
void generateTaskHubIssues();
|
|
|
|
|
|
2015-07-14 19:01:32 +02:00
|
|
|
public:
|
|
|
|
|
static ClangEditorDocumentProcessor *get(const QString &filePath);
|
|
|
|
|
|
2018-03-22 13:05:59 +01:00
|
|
|
signals:
|
|
|
|
|
void tokenInfosUpdated();
|
|
|
|
|
|
2013-12-10 14:37:32 +01:00
|
|
|
private:
|
2017-03-18 23:22:50 +02:00
|
|
|
void onParserFinished();
|
2018-05-31 15:21:53 +02:00
|
|
|
|
|
|
|
|
void updateBackendProjectPartAndDocument();
|
|
|
|
|
void updateBackendDocument(CppTools::ProjectPart &projectPart);
|
|
|
|
|
void updateBackendDocumentIfProjectPartExists();
|
2018-09-25 09:41:32 +02:00
|
|
|
void requestAnnotationsFromBackend();
|
2018-05-31 15:21:53 +02:00
|
|
|
|
2016-10-04 16:23:42 +02:00
|
|
|
HeaderErrorDiagnosticWidgetCreator creatorForHeaderErrorDiagnosticWidget(
|
|
|
|
|
const ClangBackEnd::DiagnosticContainer &firstHeaderErrorDiagnostic);
|
2018-01-12 12:29:43 +01:00
|
|
|
ClangBackEnd::FileContainer simpleFileContainer(const QByteArray &codecName = QByteArray()) const;
|
2018-01-22 09:40:04 +01:00
|
|
|
ClangBackEnd::FileContainer fileContainerWithOptionsAndDocumentContent(
|
2018-10-19 10:20:27 +02:00
|
|
|
const QStringList &compilationArguments,
|
|
|
|
|
const ProjectExplorer::HeaderPaths headerPaths) const;
|
2018-09-25 09:41:32 +02:00
|
|
|
ClangBackEnd::FileContainer fileContainerWithDocumentContent() const;
|
2015-07-14 19:01:32 +02:00
|
|
|
|
2015-08-31 16:28:26 +02:00
|
|
|
private:
|
2017-06-09 12:19:09 +02:00
|
|
|
TextEditor::TextDocument &m_document;
|
2015-09-04 12:15:17 +02:00
|
|
|
ClangDiagnosticManager m_diagnosticManager;
|
2017-09-25 15:10:48 +02:00
|
|
|
BackendCommunicator &m_communicator;
|
2015-09-01 17:34:07 +02:00
|
|
|
QSharedPointer<ClangEditorDocumentParser> m_parser;
|
2015-07-14 19:01:32 +02:00
|
|
|
CppTools::ProjectPart::Ptr m_projectPart;
|
2020-06-26 13:59:38 +02:00
|
|
|
::Utils::Id m_diagnosticConfigId;
|
2017-07-10 09:53:34 +02:00
|
|
|
bool m_isProjectFile = false;
|
2014-08-19 15:59:29 +02:00
|
|
|
QFutureWatcher<void> m_parserWatcher;
|
2018-06-05 11:40:01 +02:00
|
|
|
QTimer m_updateBackendDocumentTimer;
|
2014-08-19 15:59:29 +02:00
|
|
|
unsigned m_parserRevision;
|
2020-09-23 12:48:17 +02:00
|
|
|
enum class InvalidationState { Off, Scheduled, Canceled } m_invalidationState;
|
2014-08-19 15:59:29 +02:00
|
|
|
|
2017-12-05 09:42:35 +01:00
|
|
|
QVector<ClangBackEnd::TokenInfoContainer> m_tokenInfos;
|
2014-08-19 15:59:29 +02:00
|
|
|
CppTools::SemanticHighlighter m_semanticHighlighter;
|
|
|
|
|
CppTools::BuiltinEditorDocumentProcessor m_builtinProcessor;
|
2021-05-12 15:12:48 +02:00
|
|
|
Utils::FutureSynchronizer m_parserSynchronizer;
|
2013-12-10 14:37:32 +01:00
|
|
|
};
|
|
|
|
|
|
2015-05-08 15:48:17 +02:00
|
|
|
} // namespace Internal
|
2013-12-10 14:37:32 +01:00
|
|
|
} // namespace ClangCodeModel
|