1 | // Copyright (C) 2021 The Qt Company Ltd. |
---|---|
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #ifndef QMLLINTSUGGESTIONS_P_H |
5 | #define QMLLINTSUGGESTIONS_P_H |
6 | |
7 | // |
8 | // W A R N I N G |
9 | // ------------- |
10 | // |
11 | // This file is not part of the Qt API. It exists purely as an |
12 | // implementation detail. This header file may change from version to |
13 | // version without notice, or even be removed. |
14 | // |
15 | // We mean it. |
16 | // |
17 | |
18 | #include "qlanguageserver_p.h" |
19 | #include "qqmlcodemodel_p.h" |
20 | |
21 | #include <optional> |
22 | |
23 | QT_BEGIN_NAMESPACE |
24 | namespace QmlLsp { |
25 | struct LastLintUpdate |
26 | { |
27 | std::optional<int> version; |
28 | std::optional<QDateTime> invalidUpdatesSince; |
29 | }; |
30 | |
31 | class QmlLintSuggestions : public QLanguageServerModule |
32 | { |
33 | Q_OBJECT |
34 | public: |
35 | QmlLintSuggestions(QLanguageServer *server, QmlLsp::QQmlCodeModel *codeModel); |
36 | |
37 | QString name() const override { return QLatin1StringView("QmlLint Suggestions"); } |
38 | public Q_SLOTS: |
39 | void diagnose(const QByteArray &uri); |
40 | void registerHandlers(QLanguageServer *server, QLanguageServerProtocol *protocol) override; |
41 | void setupCapabilities(const QLspSpecification::InitializeParams &clientInfo, |
42 | QLspSpecification::InitializeResult &) override; |
43 | |
44 | private: |
45 | QMutex m_mutex; |
46 | QHash<QByteArray, LastLintUpdate> m_lastUpdate; |
47 | QLanguageServer *m_server; |
48 | QmlLsp::QQmlCodeModel *m_codeModel; |
49 | }; |
50 | } // namespace QmlLsp |
51 | QT_END_NAMESPACE |
52 | #endif // QMLLINTSUGGESTIONS_P_H |
53 |