2021-12-13 02:41:19 +00:00
|
|
|
/****************************************************************************
|
|
|
|
**
|
|
|
|
** Copyright (C) 2021 The Qt Company Ltd.
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
|
|
|
**
|
2021-12-21 13:06:26 +00:00
|
|
|
** This file is part of the tools applications of the Qt Toolkit.
|
2021-12-13 02:41:19 +00:00
|
|
|
**
|
2021-12-21 13:06:26 +00:00
|
|
|
** $QT_BEGIN_LICENSE:GPL-EXCEPT$
|
2021-12-13 02:41:19 +00:00
|
|
|
** Commercial License Usage
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
|
|
|
**
|
|
|
|
** GNU General Public License Usage
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
2021-12-21 13:06:26 +00:00
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
2021-12-13 02:41:19 +00:00
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
2021-12-21 13:06:26 +00:00
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2021-12-13 02:41:19 +00:00
|
|
|
**
|
|
|
|
** $QT_END_LICENSE$
|
|
|
|
**
|
|
|
|
****************************************************************************/
|
|
|
|
#ifndef QQMLLANGUAGESERVER_H
|
|
|
|
#define QQMLLANGUAGESERVER_H
|
|
|
|
|
|
|
|
#include "qlanguageserver_p.h"
|
|
|
|
#include "qqmlcodemodel.h"
|
|
|
|
#include "textsynchronization.h"
|
|
|
|
#include "qmllintsuggestions.h"
|
2022-01-11 13:15:42 +00:00
|
|
|
#include "workspace.h"
|
2022-04-22 10:30:27 +00:00
|
|
|
#include "../shared/qqmltoolingsettings.h"
|
2021-12-13 02:41:19 +00:00
|
|
|
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
namespace QmlLsp {
|
|
|
|
|
2022-04-28 10:20:56 +00:00
|
|
|
/*
|
|
|
|
* 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; }
|
|
|
|
|
2021-12-13 02:41:19 +00:00
|
|
|
class QQmlLanguageServer : public QLanguageServerModule
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2022-04-22 10:30:27 +00:00
|
|
|
QQmlLanguageServer(std::function<void(const QByteArray &)> sendData,
|
|
|
|
QQmlToolingSettings *settings = nullptr);
|
2021-12-13 02:41:19 +00:00
|
|
|
|
|
|
|
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();
|
2022-01-11 13:15:42 +00:00
|
|
|
WorkspaceHandlers *worspace();
|
2021-12-13 02:41:19 +00:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
void exit();
|
|
|
|
void errorExit();
|
|
|
|
|
|
|
|
private:
|
|
|
|
QQmlCodeModel m_codeModel;
|
|
|
|
QLanguageServer m_server;
|
|
|
|
TextSynchronization m_textSynchronization;
|
|
|
|
QmlLintSuggestions m_lint;
|
2022-01-11 13:15:42 +00:00
|
|
|
WorkspaceHandlers m_workspace;
|
2021-12-13 02:41:19 +00:00
|
|
|
int m_returnValue = 1;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace QmlLsp
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
#endif // QQMLLANGUAGESERVER_H
|