2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 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
|
2014-08-19 15:59:29 +02:00
|
|
|
|
2016-03-18 07:55:01 +01:00
|
|
|
#pragma once
|
2014-08-19 15:59:29 +02:00
|
|
|
|
|
|
|
|
#include "baseeditordocumentparser.h"
|
2017-05-24 13:23:01 +02:00
|
|
|
#include "cppcursorinfo.h"
|
2021-08-30 10:58:08 +02:00
|
|
|
#include "cppeditor_global.h"
|
2021-09-02 13:31:08 +02:00
|
|
|
#include "cppsemanticinfo.h"
|
|
|
|
|
#include "cpptoolsreuse.h"
|
2014-08-19 15:59:29 +02:00
|
|
|
|
2019-01-24 11:30:58 +01:00
|
|
|
#include <coreplugin/helpitem.h>
|
2022-11-21 16:48:50 +01:00
|
|
|
|
2015-08-24 18:26:09 +02:00
|
|
|
#include <texteditor/codeassist/assistinterface.h>
|
2016-11-18 11:53:38 +01:00
|
|
|
#include <texteditor/quickfix.h>
|
2014-09-26 09:14:03 +02:00
|
|
|
#include <texteditor/texteditor.h>
|
2015-02-26 13:22:35 +01:00
|
|
|
#include <texteditor/textdocument.h>
|
2014-08-19 15:59:29 +02:00
|
|
|
|
|
|
|
|
#include <cplusplus/CppDocument.h>
|
|
|
|
|
|
|
|
|
|
#include <QTextEdit>
|
2020-05-18 17:40:19 +02:00
|
|
|
#include <QVariant>
|
|
|
|
|
|
2016-10-04 16:23:42 +02:00
|
|
|
#include <functional>
|
|
|
|
|
|
2021-08-30 10:58:08 +02:00
|
|
|
namespace TextEditor { class TextDocument; }
|
2015-02-26 13:22:35 +01:00
|
|
|
|
2021-08-30 10:58:08 +02:00
|
|
|
namespace CppEditor {
|
2014-08-19 15:59:29 +02:00
|
|
|
|
2018-01-12 12:29:43 +01:00
|
|
|
// For clang code model only, move?
|
2023-01-11 20:43:10 +01:00
|
|
|
struct CPPEDITOR_EXPORT ToolTipInfo
|
|
|
|
|
{
|
2018-01-12 12:29:43 +01:00
|
|
|
QString text;
|
|
|
|
|
QString briefComment;
|
|
|
|
|
|
|
|
|
|
QStringList qDocIdCandidates;
|
|
|
|
|
QString qDocMark;
|
2019-01-24 11:30:58 +01:00
|
|
|
Core::HelpItem::Category qDocCategory;
|
2020-05-18 17:40:19 +02:00
|
|
|
QVariant value;
|
2018-01-12 12:29:43 +01:00
|
|
|
|
|
|
|
|
QString sizeInBytes;
|
|
|
|
|
};
|
|
|
|
|
|
2021-08-30 10:58:08 +02:00
|
|
|
class CPPEDITOR_EXPORT BaseEditorDocumentProcessor : public QObject
|
2014-08-19 15:59:29 +02:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
2022-11-21 16:48:50 +01:00
|
|
|
BaseEditorDocumentProcessor(QTextDocument *textDocument, const Utils::FilePath &filePath);
|
2018-05-07 15:06:32 +02:00
|
|
|
~BaseEditorDocumentProcessor() override;
|
2014-08-19 15:59:29 +02:00
|
|
|
|
2017-01-19 15:46:40 +01:00
|
|
|
void run(bool projectsUpdated = false);
|
2015-06-19 14:43:41 +02:00
|
|
|
virtual void semanticRehighlight() = 0;
|
2015-06-19 14:37:26 +02:00
|
|
|
virtual void recalculateSemanticInfoDetached(bool force) = 0;
|
2021-08-30 10:58:08 +02:00
|
|
|
virtual SemanticInfo recalculateSemanticInfo() = 0;
|
2014-11-28 12:03:58 +01:00
|
|
|
virtual CPlusPlus::Snapshot snapshot() = 0;
|
2015-09-01 17:34:07 +02:00
|
|
|
virtual BaseEditorDocumentParser::Ptr parser() = 0;
|
2014-08-19 15:59:29 +02:00
|
|
|
virtual bool isParserRunning() const = 0;
|
|
|
|
|
|
2015-08-24 18:26:09 +02:00
|
|
|
virtual TextEditor::QuickFixOperations
|
|
|
|
|
extraRefactoringOperations(const TextEditor::AssistInterface &assistInterface);
|
|
|
|
|
|
2017-07-03 13:29:30 +02:00
|
|
|
virtual void invalidateDiagnostics();
|
2016-01-27 13:37:19 +01:00
|
|
|
|
2019-01-14 01:40:53 +01:00
|
|
|
virtual void setParserConfig(const BaseEditorDocumentParser::Configuration &config);
|
2017-01-18 15:05:46 +01:00
|
|
|
|
2017-05-24 13:23:01 +02:00
|
|
|
virtual QFuture<CursorInfo> cursorInfo(const CursorInfoParams ¶ms) = 0;
|
|
|
|
|
|
2022-11-21 16:48:50 +01:00
|
|
|
const Utils::FilePath &filePath() const { return m_filePath; }
|
2018-01-19 16:57:18 +01:00
|
|
|
|
2014-08-19 15:59:29 +02:00
|
|
|
signals:
|
|
|
|
|
// Signal interface to implement
|
2021-08-30 10:58:08 +02:00
|
|
|
void projectPartInfoUpdated(const ProjectPartInfo &projectPartInfo);
|
2017-01-17 15:27:31 +01:00
|
|
|
|
2014-08-19 15:59:29 +02:00
|
|
|
void codeWarningsUpdated(unsigned revision,
|
2019-01-14 01:40:53 +01:00
|
|
|
const QList<QTextEdit::ExtraSelection> &selections,
|
2016-02-05 15:16:02 +01:00
|
|
|
const TextEditor::RefactorMarkers &refactorMarkers);
|
2014-08-19 15:59:29 +02:00
|
|
|
|
|
|
|
|
void ifdefedOutBlocksUpdated(unsigned revision,
|
2019-01-14 01:40:53 +01:00
|
|
|
const QList<TextEditor::BlockRange> &ifdefedOutBlocks);
|
2014-08-19 15:59:29 +02:00
|
|
|
|
|
|
|
|
void cppDocumentUpdated(const CPlusPlus::Document::Ptr document); // TODO: Remove me
|
2021-08-30 10:58:08 +02:00
|
|
|
void semanticInfoUpdated(const SemanticInfo semanticInfo); // TODO: Remove me
|
2014-08-19 15:59:29 +02:00
|
|
|
|
|
|
|
|
protected:
|
2023-03-03 22:18:46 +01:00
|
|
|
static void runParser(QPromise<void> &promise,
|
2015-09-01 17:34:07 +02:00
|
|
|
BaseEditorDocumentParser::Ptr parser,
|
2016-12-14 18:58:23 +01:00
|
|
|
BaseEditorDocumentParser::UpdateParams updateParams);
|
2014-08-19 15:59:29 +02:00
|
|
|
|
|
|
|
|
// Convenience
|
2016-01-11 20:40:05 +01:00
|
|
|
unsigned revision() const { return static_cast<unsigned>(m_textDocument->revision()); }
|
|
|
|
|
QTextDocument *textDocument() const { return m_textDocument; }
|
2014-08-19 15:59:29 +02:00
|
|
|
|
2016-12-14 18:58:23 +01:00
|
|
|
private:
|
|
|
|
|
virtual void runImpl(const BaseEditorDocumentParser::UpdateParams &updateParams) = 0;
|
|
|
|
|
|
2014-08-19 15:59:29 +02:00
|
|
|
private:
|
2022-11-21 16:48:50 +01:00
|
|
|
Utils::FilePath m_filePath;
|
2016-01-11 20:40:05 +01:00
|
|
|
QTextDocument *m_textDocument;
|
2014-08-19 15:59:29 +02:00
|
|
|
};
|
|
|
|
|
|
2021-08-30 10:58:08 +02:00
|
|
|
} // namespace CppEditor
|