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 | |
13 | namespace newlsp { |
14 | |
15 | class ClientPrivate; |
16 | class Client : public QProcess |
17 | { |
18 | Q_OBJECT |
19 | ClientPrivate *const d; |
20 | public: |
21 | explicit Client(); |
22 | virtual ~Client(); |
23 | |
24 | lsp::SemanticTokensProvider initSecTokensProvider(); |
25 | |
26 | public slots: |
27 | // textDocument/semanticTokens/full/delta |
28 | void delta(const newlsp::SemanticTokensDeltaParams ¶ms); |
29 | // textDocument/semanticTokens/full |
30 | void full(const newlsp::SemanticTokensParams ¶ms); |
31 | // textDocument/semanticTokens/range |
32 | void range(const newlsp::SemanticTokensRangeParams ¶ms); |
33 | |
34 | // Notifications send to server |
35 | // textDocument/didOpen |
36 | void didOpen(const newlsp::DidOpenTextDocumentParams ¶ms); |
37 | // textDocument/didChange |
38 | void didChange(const newlsp::DidChangeTextDocumentParams ¶ms); |
39 | // textDocument/willSave |
40 | void willSave(const newlsp::WillSaveTextDocumentParams ¶ms); |
41 | // textDocument/willSaveWaitUntil |
42 | void willSaveWaitUntil(const newlsp::WillSaveTextDocumentParams ¶ms); |
43 | // textDocument/didSave |
44 | void didSave(const newlsp::DidSaveTextDocumentParams ¶ms); |
45 | // textDocument/didClose |
46 | void didClose(const newlsp::DidCloseTextDocumentParams ¶ms); |
47 | |
48 | // Requests |
49 | // textDocument/declaration |
50 | void declaration(const newlsp::DeclarationParams ¶ms); |
51 | // textDocument/definition |
52 | void definition(const newlsp::DefinitionParams ¶ms); |
53 | // textDocument/typeDefinition |
54 | void typeDefinition(const newlsp::TypeDefinitionParams ¶ms); |
55 | // textDocument/implementation |
56 | void implementation(const newlsp::ImplementationParams ¶ms); |
57 | // textDocument/references |
58 | void references(const newlsp::ReferenceParams ¶ms); |
59 | // textDocument/prepareCallHierarchy |
60 | void prepareCallHierarchy(const newlsp::CallHierarchyPrepareParams ¶ms); |
61 | // textDocument/prepareTypeHierarchy |
62 | void prepareTypeHierarchy(const newlsp::TypeHierarchyPrepareParams ¶ms); |
63 | // textDocument/documentHighlight |
64 | void documentHighlight(const newlsp::DocumentHighlightParams ¶ms); |
65 | // textDocument/documentLink |
66 | void documentLink(const newlsp::DocumentLinkParams ¶ms); |
67 | // textDocument/hover |
68 | void hover(const newlsp::HoverParams ¶ms); |
69 | // textDocument/codeLens |
70 | void codeLens(const newlsp::CodeLensParams ¶ms); |
71 | // textDocument/foldingRange |
72 | void foldingRange(const newlsp::FoldingRangeParams ¶ms); |
73 | // textDocument/selectionRange |
74 | void selectionRange(const newlsp::SelectionRangeParams ¶ms); |
75 | // textDocument/documentSymbol |
76 | void documentSymbol(const newlsp::DocumentSymbolParams ¶ms); |
77 | // textDocument/inlayHint |
78 | void inlayHint(const newlsp::InlayHintParams ¶ms); |
79 | // textDocument/inlineValue |
80 | void inlineValue(const newlsp::InlineValueParams ¶ms); |
81 | // textDocument/moniker |
82 | void moniker(const newlsp::MonikerParams ¶ms); |
83 | // textDocument/completion |
84 | void completion(const newlsp::CompletionParams ¶ms); |
85 | // textDocument/diagnostic is request |
86 | void diagnostic(const newlsp::DocumentDiagnosticParams ¶ms); |
87 | // textDocument/signatureHelp |
88 | void signatureHelp(const newlsp::SignatureHelpParams ¶ms); |
89 | // textDocument/codeAction |
90 | void codeAction(const newlsp::CodeActionParams ¶ms); |
91 | // textDocument/documentColor |
92 | void documentColor(const newlsp::DocumentColorParams ¶ms); |
93 | // textDocument/colorPresentation |
94 | void colorPresentation(const newlsp::ColorPresentationParams ¶ms); |
95 | // textDocument/formatting |
96 | void formatting(const newlsp::DocumentFormattingParams ¶ms); |
97 | // textDocument/rangeFormatting |
98 | void rangeFormatting(const newlsp::DocumentRangeFormattingParams ¶ms); |
99 | // textDocument/onTypeFormatting |
100 | void onTypeFormatting(const newlsp::DocumentOnTypeFormattingParams ¶ms); |
101 | // textDocument/rename |
102 | void rename(const newlsp::RenameParams ¶ms); |
103 | // textDocument/prepareRename |
104 | void prepareRename(const newlsp::PrepareRenameParams ¶ms); |
105 | // textDocument/linkedEditingRange |
106 | void linkedEditingRange(const newlsp::LinkedEditingRangeParams ¶ms); |
107 | |
108 | // codeAction/resolve |
109 | void resolve(const newlsp::CodeAction &codeAction); |
110 | // completionItem/resolve |
111 | void resolve(const newlsp::CompletionItem ¶ms); |
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 ¶ms); |
119 | // typeHierarchy/subtypes |
120 | void subtypes(const newlsp::TypeHierarchySubtypesParams ¶ms); |
121 | |
122 | // callHierarchy/incomingCalls |
123 | void incomingCalls(const newlsp::CallHierarchyIncomingCallsParams ¶ms); |
124 | // callHierarchy/outgoingCalls |
125 | void outgoingCalls(const newlsp::CallHierarchyOutgoingCallsParams ¶ms); |
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 ¶ms); |
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 | |
162 | signals: |
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 | |