1// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: GPL-3.0-or-later
4
5#ifndef CLIENT_H
6#define CLIENT_H
7
8#include "common/lsp/protocol/protocol.h"
9#include "common/lsp/protocol/newprotocol.h"
10
11#include <QThread>
12
13namespace newlsp {
14
15class ClientPrivate;
16class Client : public QProcess
17{
18 Q_OBJECT
19 ClientPrivate *const d;
20public:
21 explicit Client();
22 virtual ~Client();
23
24 lsp::SemanticTokensProvider initSecTokensProvider();
25
26public slots:
27 // textDocument/semanticTokens/full/delta
28 void delta(const newlsp::SemanticTokensDeltaParams &params);
29 // textDocument/semanticTokens/full
30 void full(const newlsp::SemanticTokensParams &params);
31 // textDocument/semanticTokens/range
32 void range(const newlsp::SemanticTokensRangeParams &params);
33
34 // Notifications send to server
35 // textDocument/didOpen
36 void didOpen(const newlsp::DidOpenTextDocumentParams &params);
37 // textDocument/didChange
38 void didChange(const newlsp::DidChangeTextDocumentParams &params);
39 // textDocument/willSave
40 void willSave(const newlsp::WillSaveTextDocumentParams &params);
41 // textDocument/willSaveWaitUntil
42 void willSaveWaitUntil(const newlsp::WillSaveTextDocumentParams &params);
43 // textDocument/didSave
44 void didSave(const newlsp::DidSaveTextDocumentParams &params);
45 // textDocument/didClose
46 void didClose(const newlsp::DidCloseTextDocumentParams &params);
47
48 // Requests
49 // textDocument/declaration
50 void declaration(const newlsp::DeclarationParams &params);
51 // textDocument/definition
52 void definition(const newlsp::DefinitionParams &params);
53 // textDocument/typeDefinition
54 void typeDefinition(const newlsp::TypeDefinitionParams &params);
55 // textDocument/implementation
56 void implementation(const newlsp::ImplementationParams &params);
57 // textDocument/references
58 void references(const newlsp::ReferenceParams &params);
59 // textDocument/prepareCallHierarchy
60 void prepareCallHierarchy(const newlsp::CallHierarchyPrepareParams &params);
61 // textDocument/prepareTypeHierarchy
62 void prepareTypeHierarchy(const newlsp::TypeHierarchyPrepareParams &params);
63 // textDocument/documentHighlight
64 void documentHighlight(const newlsp::DocumentHighlightParams &params);
65 // textDocument/documentLink
66 void documentLink(const newlsp::DocumentLinkParams &params);
67 // textDocument/hover
68 void hover(const newlsp::HoverParams &params);
69 // textDocument/codeLens
70 void codeLens(const newlsp::CodeLensParams &params);
71 // textDocument/foldingRange
72 void foldingRange(const newlsp::FoldingRangeParams &params);
73 // textDocument/selectionRange
74 void selectionRange(const newlsp::SelectionRangeParams &params);
75 // textDocument/documentSymbol
76 void documentSymbol(const newlsp::DocumentSymbolParams &params);
77 // textDocument/inlayHint
78 void inlayHint(const newlsp::InlayHintParams &params);
79 // textDocument/inlineValue
80 void inlineValue(const newlsp::InlineValueParams &params);
81 // textDocument/moniker
82 void moniker(const newlsp::MonikerParams &params);
83 // textDocument/completion
84 void completion(const newlsp::CompletionParams &params);
85 // textDocument/diagnostic is request
86 void diagnostic(const newlsp::DocumentDiagnosticParams &params);
87 // textDocument/signatureHelp
88 void signatureHelp(const newlsp::SignatureHelpParams &params);
89 // textDocument/codeAction
90 void codeAction(const newlsp::CodeActionParams &params);
91 // textDocument/documentColor
92 void documentColor(const newlsp::DocumentColorParams &params);
93 // textDocument/colorPresentation
94 void colorPresentation(const newlsp::ColorPresentationParams &params);
95 // textDocument/formatting
96 void formatting(const newlsp::DocumentFormattingParams &params);
97 // textDocument/rangeFormatting
98 void rangeFormatting(const newlsp::DocumentRangeFormattingParams &params);
99 // textDocument/onTypeFormatting
100 void onTypeFormatting(const newlsp::DocumentOnTypeFormattingParams &params);
101 // textDocument/rename
102 void rename(const newlsp::RenameParams &params);
103 // textDocument/prepareRename
104 void prepareRename(const newlsp::PrepareRenameParams &params);
105 // textDocument/linkedEditingRange
106 void linkedEditingRange(const newlsp::LinkedEditingRangeParams &params);
107
108 // codeAction/resolve
109 void resolve(const newlsp::CodeAction &codeAction);
110 // completionItem/resolve
111 void resolve(const newlsp::CompletionItem &params);
112 // inlayHint/resolve
113 void resolve();
114 // codeLens/resolve
115 void resolve(const newlsp::CodeLens &codeLens);
116
117 // typeHierarchy/supertypes
118 void supertypes(const newlsp::TypeHierarchySupertypesParams &params);
119 // typeHierarchy/subtypes
120 void subtypes(const newlsp::TypeHierarchySubtypesParams &params);
121
122 // callHierarchy/incomingCalls
123 void incomingCalls(const newlsp::CallHierarchyIncomingCallsParams &params);
124 // callHierarchy/outgoingCalls
125 void outgoingCalls(const newlsp::CallHierarchyOutgoingCallsParams &params);
126
127 // workspace/codelens/refresh
128 void refresh();
129
130 // workspace/semanticTokens/refresh
131 void workspace_semanticTokens_refresh();
132
133 // workspace/inlayHint/refresh
134 void workspace_inlayHint_refresh();
135
136 // workspace/inlineValue/refresh
137 void workspace_inlineValue_refresh();
138
139 // workspace/diagnostic/refresh
140 void workspace_diagnostic_refresh();
141
142 // workspace/diagnostic
143 void diagnostic(const newlsp::WorkspaceDiagnosticParams &params);
144
145 void selectLspServer(const newlsp::ProjectKey &key);
146 void initRequest(const QString &compile); // yes
147 void shutdownRequest();
148 void exitRequest();
149 void openRequest(const QString &filePath); // yes
150 void closeRequest(const QString &filePath); // yes
151 void changeRequest(const QString &filePath, const QByteArray &text); // yes
152 void symbolRequest(const QString &filePath); // yes
153 void renameRequest(const QString &filePath, const lsp::Position &pos, const QString &newName); //yes
154 void definitionRequest(const QString &filePath, const lsp::Position &pos); // yes
155 void completionRequest(const QString &filePath, const lsp::Position &pos); // yes
156 void signatureHelpRequest(const QString &filePath, const lsp::Position &pos); // yes
157 void referencesRequest(const QString &filePath, const lsp::Position &pos);
158 void docHighlightRequest(const QString &filePath, const lsp::Position &pos);
159 void docSemanticTokensFull(const QString &filePath); //yes
160 void docHoverRequest(const QString &filePath, const lsp::Position &pos); // yes
161
162signals:
163 void request();
164 void notification(const QString &jsonStr);
165 void requestResult(const lsp::SemanticTokensProvider &tokensProvider);
166 void requestResult(const lsp::Symbols &symbols);
167 void requestResult(const lsp::Locations &locations);
168 void requestResult(const lsp::CompletionProvider &completionProvider);
169 void requestResult(const lsp::SignatureHelps &signatureHelps);
170 void requestResult(const lsp::Highlights &highlights);
171 void requestResult(const QList<lsp::Data> &tokensResult);
172 void requestResult(const lsp::References &refs);
173 void renameRes(const newlsp::WorkspaceEdit &changes);
174 void hoverRes(const newlsp::Hover &hover);
175 void definitionRes(const newlsp::Location &location);
176 void definitionRes(const std::vector<newlsp::Location> &locations);
177 void definitionRes(const std::vector<newlsp::LocationLink> &locations);
178 void rangeFormattingRes(const std::vector<TextEdit> &edits);
179
180 /* server request */
181 void publishDiagnostics(const newlsp::PublishDiagnosticsParams &diagnostics); // textDocument/publishDiagnostics
182};
183} // namespace newlsp
184
185#endif // CLIENT_H
186