blob: 7efe93990aa4fc0be9ff34276d24a43c8801d4bb (
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
|
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#ifndef QQMLLANGUAGESERVER_H
#define QQMLLANGUAGESERVER_H
#include "qlanguageserver_p.h"
#include "qqmlcodemodel.h"
#include "textsynchronization.h"
#include "qmllintsuggestions.h"
#include "workspace.h"
#include "qmlcompletionsupport.h"
#include "../shared/qqmltoolingsettings.h"
QT_BEGIN_NAMESPACE
namespace QmlLsp {
/*
* The language server protocol calls "URI" what QML calls "URL".
* According to RFC 3986, a URL is a special case of URI that not only
* identifies a resource but also shows how to access it.
* In QML, however, URIs are distinct from URLs. URIs are the
* identifiers of modules, for example "QtQuick.Controls".
* In order to not confuse the terms we interpret language server URIs
* as URLs in the QML code model.
* This method marks a point of translation between the terms, but does
* not have to change the actual URI/URL.
*/
inline QByteArray lspUriToQmlUrl(const QByteArray &uri) { return uri; }
class QQmlLanguageServer : public QLanguageServerModule
{
Q_OBJECT
public:
QQmlLanguageServer(std::function<void(const QByteArray &)> sendData,
QQmlToolingSettings *settings = nullptr);
QString name() const final;
void registerHandlers(QLanguageServer *server, QLanguageServerProtocol *protocol) final;
void setupCapabilities(const QLspSpecification::InitializeParams &clientInfo,
QLspSpecification::InitializeResult &serverInfo) final;
int returnValue() const;
QQmlCodeModel *codeModel();
QLanguageServer *server();
TextSynchronization *textSynchronization();
QmlLintSuggestions *lint();
WorkspaceHandlers *worspace();
public Q_SLOTS:
void exit();
void errorExit();
private:
QQmlCodeModel m_codeModel;
QLanguageServer m_server;
TextSynchronization m_textSynchronization;
QmlLintSuggestions m_lint;
WorkspaceHandlers m_workspace;
QmlCompletionSupport m_completionSupport;
int m_returnValue = 1;
};
} // namespace QmlLsp
QT_END_NAMESPACE
#endif // QQMLLANGUAGESERVER_H
|