1 | // Copyright (C) 2018 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 QQMLCOMPLETIONSUPPORT_P_H |
5 | #define QQMLCOMPLETIONSUPPORT_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 "qqmlbasemodule_p.h" |
20 | #include "qqmlcodemodel_p.h" |
21 | |
22 | #include <QtCore/qmutex.h> |
23 | #include <QtCore/qhash.h> |
24 | |
25 | QT_BEGIN_NAMESPACE |
26 | struct CompletionRequest |
27 | : BaseRequest<QLspSpecification::CompletionParams, |
28 | QLspSpecification::LSPPartialResponse< |
29 | std::variant<QList<QLspSpecification::CompletionItem>, |
30 | QLspSpecification::CompletionList, std::nullptr_t>, |
31 | std::variant<QLspSpecification::CompletionList, |
32 | QList<QLspSpecification::CompletionItem>>>> |
33 | { |
34 | QString code; |
35 | |
36 | bool fillFrom(QmlLsp::OpenDocument doc, const Parameters ¶ms, Response &&response); |
37 | void sendCompletions(QmlLsp::OpenDocumentSnapshot &); |
38 | QString urlAndPos() const; |
39 | QList<QLspSpecification::CompletionItem> completions(QmlLsp::OpenDocumentSnapshot &doc) const; |
40 | }; |
41 | |
42 | class QmlCompletionSupport : public QQmlBaseModule<CompletionRequest> |
43 | { |
44 | Q_OBJECT |
45 | public: |
46 | using BaseT::BaseT; |
47 | QString name() const override; |
48 | void registerHandlers(QLanguageServer *server, QLanguageServerProtocol *protocol) override; |
49 | void setupCapabilities(const QLspSpecification::InitializeParams &clientInfo, |
50 | QLspSpecification::InitializeResult &) override; |
51 | void process(RequestPointerArgument req) override; |
52 | }; |
53 | QT_END_NAMESPACE |
54 | |
55 | #endif // QMLCOMPLETIONSUPPORT_P_H |
56 | |