blob: ef84b94ef315c1ce3ae6f74c44ff6c3d7c1f469a (
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QQMLHIGHLIGHTSUPPORT_P_H
#define QQMLHIGHLIGHTSUPPORT_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include "qlanguageserver_p.h"
#include "qqmlbasemodule_p.h"
#include "qqmlcodemodel_p.h"
QT_BEGIN_NAMESPACE
// We don't need these overrides as we register the request handlers in a single
// module QQmlHighlightSupport. This is an unusual pattern because QQmlBaseModule
// and QLanguageServerModule abstractions are designed to handle a single module
// which has a single request handlers. That is not the case for the semanticTokens
// module which has a one server module but also has three different handlers.
#define HIDE_UNUSED_OVERRIDES \
private: \
QString name() const override \
{ \
return {}; \
} \
void setupCapabilities(const QLspSpecification::InitializeParams &, \
QLspSpecification::InitializeResult &) override \
{ \
}
using SemanticTokensRequest = BaseRequest<QLspSpecification::SemanticTokensParams,
QLspSpecification::Responses::SemanticTokensResponseType>;
using SemanticTokensDeltaRequest =
BaseRequest<QLspSpecification::SemanticTokensDeltaParams,
QLspSpecification::Responses::SemanticTokensDeltaResponseType>;
using SemanticTokensRangeRequest =
BaseRequest<QLspSpecification::SemanticTokensRangeParams,
QLspSpecification::Responses::SemanticTokensRangeResponseType>;
class SemanticTokenFullHandler : public QQmlBaseModule<SemanticTokensRequest>
{
public:
SemanticTokenFullHandler(QmlLsp::QQmlCodeModel *codeModel);
void process(QQmlBaseModule<SemanticTokensRequest>::RequestPointerArgument req) override;
void registerHandlers(QLanguageServer *, QLanguageServerProtocol *) override;
HIDE_UNUSED_OVERRIDES
};
class SemanticTokenDeltaHandler : public QQmlBaseModule<SemanticTokensDeltaRequest>
{
public:
SemanticTokenDeltaHandler(QmlLsp::QQmlCodeModel *codeModel);
void process(QQmlBaseModule<SemanticTokensDeltaRequest>::RequestPointerArgument req) override;
void registerHandlers(QLanguageServer *, QLanguageServerProtocol *) override;
HIDE_UNUSED_OVERRIDES
};
class SemanticTokenRangeHandler : public QQmlBaseModule<SemanticTokensRangeRequest>
{
public:
SemanticTokenRangeHandler(QmlLsp::QQmlCodeModel *codeModel);
void process(QQmlBaseModule<SemanticTokensRangeRequest>::RequestPointerArgument req) override;
void registerHandlers(QLanguageServer *, QLanguageServerProtocol *) override;
HIDE_UNUSED_OVERRIDES
};
class QQmlHighlightSupport : public QLanguageServerModule
{
public:
QQmlHighlightSupport(QmlLsp::QQmlCodeModel *codeModel);
QString name() const override;
void registerHandlers(QLanguageServer *server, QLanguageServerProtocol *protocol) override;
void setupCapabilities(const QLspSpecification::InitializeParams &clientInfo,
QLspSpecification::InitializeResult &) override;
private:
SemanticTokenFullHandler m_full;
SemanticTokenDeltaHandler m_delta;
SemanticTokenRangeHandler m_range;
};
#undef HIDE_UNUSED_OVERRIDES
QT_END_NAMESPACE
#endif // QQMLHIGHLIGHTSUPPORT_P_H
|