| 1 | // SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. |
|---|---|
| 2 | // |
| 3 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 4 | |
| 5 | #ifndef CLIENT_P_H |
| 6 | #define CLIENT_P_H |
| 7 | |
| 8 | #include "common/lsp/client/stdoutjsonrpcparser.h" |
| 9 | #include "common/lsp/protocol/newprotocol.h" |
| 10 | #include "common/lsp/protocol/protocol.h" |
| 11 | |
| 12 | #include <QHash> |
| 13 | |
| 14 | namespace newlsp { |
| 15 | |
| 16 | class Client; |
| 17 | class ClientPrivate : public newlsp::StdoutJsonRpcParser |
| 18 | { |
| 19 | Q_OBJECT |
| 20 | friend class Client; |
| 21 | Client *const q; |
| 22 | int requestIndex; |
| 23 | QHash<int, QString> requestSave; |
| 24 | int semanticTokenResultId; |
| 25 | QHash<QString, int> fileVersion; |
| 26 | lsp::SemanticTokensProvider secTokensProvider; |
| 27 | newlsp::ProjectKey proKey; |
| 28 | |
| 29 | ClientPrivate(Client *const q); |
| 30 | |
| 31 | QStringList cvtStringList(const QJsonArray &array); |
| 32 | |
| 33 | /* server response parse */ |
| 34 | bool calledError(const QJsonObject &jsonObj); |
| 35 | bool calledResult(const QJsonObject &jsonObj); //found result key from json && not found method |
| 36 | bool initResult(const QJsonObject &jsonObj); // client call server rpc return |
| 37 | bool openResult(const QJsonObject &jsonObj); // client call server rpc return |
| 38 | bool changeResult(const QJsonObject &jsonObj); // client call server rpc return |
| 39 | bool symbolResult(const QJsonObject &jsonObj); // client call server rpc return |
| 40 | bool renameResult(const QJsonObject &jsonObj); // client call server rpc return |
| 41 | bool definitionResult(const QJsonObject &jsonObj); // client call server rpc return above uri |
| 42 | bool completionResult(const QJsonObject &jsonObj); // client call server rpc return |
| 43 | bool rangeFormattingResult(const QJsonObject &jsonObj); // client call server rpc return |
| 44 | bool signatureHelpResult(const QJsonObject &jsonObj); // client call server rpc return |
| 45 | bool hoverResult(const QJsonObject &jsonObj); // client call server rpc return |
| 46 | bool referencesResult(const QJsonObject &jsonObj); // client call server rpc return |
| 47 | bool docHighlightResult(const QJsonObject &jsonObj); // client call server rpc return |
| 48 | bool docSemanticTokensFullResult(const QJsonObject &jsonObj); // client call server rpc return |
| 49 | bool closeResult(const QJsonObject &jsonObj); // client call server rpc return |
| 50 | bool shutdownResult(const QJsonObject &jsonObj); |
| 51 | bool exitResult(const QJsonObject &jsonObj); |
| 52 | |
| 53 | /* server called method */ |
| 54 | bool serverCalled(const QJsonObject &jsonObj); // not found result key from json && found key method |
| 55 | bool diagnosticsCalled(const QJsonObject &jsonObj); |
| 56 | |
| 57 | public Q_SLOTS: |
| 58 | // readed parse |
| 59 | void doReadStdoutLine(); |
| 60 | void identifyJsonObject(const QJsonObject &jsonObj); |
| 61 | |
| 62 | void callMethod(const QString &method, const QJsonObject ¶ms); |
| 63 | void callNotification(const QString &method, const QJsonObject ¶ms); |
| 64 | void writeLspData(const QByteArray &jsonObj); |
| 65 | }; |
| 66 | |
| 67 | } |
| 68 | |
| 69 | #endif // CLIENT_P_H |
| 70 |