blob: a93db1f5f82cf8e4cb657a0d5816842fc1d059cd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
#include "../cppeditor_global.h"
#include "cppquickfixassistant.h"
#include <extensionsystem/iplugin.h>
#include <texteditor/quickfix.h>
#include <QVersionNumber>
#include <optional>
namespace CppEditor {
namespace Internal {
class CppQuickFixInterface;
class CppQuickFixOperation
: public TextEditor::QuickFixOperation,
public Internal::CppQuickFixInterface
{
public:
explicit CppQuickFixOperation(const CppQuickFixInterface &interface, int priority = -1);
~CppQuickFixOperation() override;
};
} // namespace Internal
/*!
The QuickFixFactory is responsible for generating QuickFixOperation s which are
applicable to the given QuickFixState.
A QuickFixFactory should not have any state -- it can be invoked multiple times
for different QuickFixState objects to create the matching operations, before any
of those operations are applied (or released).
This way, a single factory can be used by multiple editors, and a single editor
can have multiple QuickFixCollector objects for different parts of the code.
*/
class CPPEDITOR_EXPORT CppQuickFixFactory : public QObject
{
Q_OBJECT
public:
CppQuickFixFactory();
~CppQuickFixFactory() override;
using QuickFixOperations = TextEditor::QuickFixOperations;
void match(const Internal::CppQuickFixInterface &interface, QuickFixOperations &result);
static const QList<CppQuickFixFactory *> &cppQuickFixFactories();
std::optional<QVersionNumber> clangdReplacement() const { return m_clangdReplacement; }
void setClangdReplacement(const QVersionNumber &version) { m_clangdReplacement = version; }
template<class Factory> static void registerFactory()
{
new Factory;
#ifdef WITH_TESTS
cppEditor()->addTestCreator(Factory::createTest);
#endif
}
private:
/*!
Implement this function to doMatch and create the appropriate
CppQuickFixOperation objects.
*/
virtual void doMatch(const Internal::CppQuickFixInterface &interface,
QuickFixOperations &result) = 0;
static ExtensionSystem::IPlugin *cppEditor();
std::optional<QVersionNumber> m_clangdReplacement;
};
} // namespace CppEditor
|