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 | #include <QtQmlLS/private/qqmllscompletion_p.h> |
25 | |
26 | QT_BEGIN_NAMESPACE |
27 | struct CompletionRequest |
28 | : BaseRequest<QLspSpecification::CompletionParams, |
29 | QLspSpecification::LSPPartialResponse< |
30 | std::variant<QList<QLspSpecification::CompletionItem>, |
31 | QLspSpecification::CompletionList, std::nullptr_t>, |
32 | std::variant<QLspSpecification::CompletionList, |
33 | QList<QLspSpecification::CompletionItem>>>> |
34 | { |
35 | QString code; |
36 | |
37 | bool fillFrom(QmlLsp::OpenDocument doc, const Parameters ¶ms, Response &&response); |
38 | void sendCompletions(const QList<QLspSpecification::CompletionItem> &completions); |
39 | QString urlAndPos() const; |
40 | QList<QLspSpecification::CompletionItem> |
41 | completions(QmlLsp::OpenDocumentSnapshot &doc, const QQmlLSCompletion &completionEngine) const; |
42 | QQmlJS::Dom::DomItem patchInvalidFileForParser(const QQmlJS::Dom::DomItem &file, |
43 | qsizetype position) const; |
44 | }; |
45 | |
46 | class QmlCompletionSupport : public QQmlBaseModule<CompletionRequest> |
47 | { |
48 | Q_OBJECT |
49 | public: |
50 | QmlCompletionSupport(QmlLsp::QQmlCodeModel *codeModel); |
51 | QString name() const override; |
52 | void registerHandlers(QLanguageServer *server, QLanguageServerProtocol *protocol) override; |
53 | void setupCapabilities(const QLspSpecification::InitializeParams &clientInfo, |
54 | QLspSpecification::InitializeResult &) override; |
55 | void process(RequestPointerArgument req) override; |
56 | |
57 | QQmlLSCompletion m_completionEngine; |
58 | }; |
59 | QT_END_NAMESPACE |
60 | |
61 | #endif // QMLCOMPLETIONSUPPORT_P_H |
62 | |