@@ -85,7 +85,8 @@ void ClangdLSPServer::onDocumentDidOpen(Ctx C,
85
85
void ClangdLSPServer::onDocumentDidChange (Ctx C,
86
86
DidChangeTextDocumentParams &Params) {
87
87
if (Params.contentChanges .size () != 1 )
88
- return C.replyError (-32602 , " can only apply one change at a time" );
88
+ return C.replyError (ErrorCode::InvalidParams,
89
+ " can only apply one change at a time" );
89
90
// We only support full syncing right now.
90
91
Server.addDocument (Params.textDocument .uri .file ,
91
92
Params.contentChanges [0 ].text );
@@ -119,7 +120,8 @@ void ClangdLSPServer::onCommand(Ctx C, ExecuteCommandParams &Params) {
119
120
// parsed in the first place and this handler should not be called. But if
120
121
// more commands are added, this will be here has a safe guard.
121
122
C.replyError (
122
- 1 , llvm::formatv (" Unsupported command \" {0}\" ." , Params.command ).str ());
123
+ ErrorCode::InvalidParams,
124
+ llvm::formatv (" Unsupported command \" {0}\" ." , Params.command ).str ());
123
125
}
124
126
}
125
127
@@ -191,7 +193,8 @@ void ClangdLSPServer::onSignatureHelp(Ctx C,
191
193
Params.textDocument .uri .file ,
192
194
Position{Params.position .line , Params.position .character });
193
195
if (!SignatureHelp)
194
- return C.replyError (-32602 , llvm::toString (SignatureHelp.takeError ()));
196
+ return C.replyError (ErrorCode::InvalidParams,
197
+ llvm::toString (SignatureHelp.takeError ()));
195
198
C.reply (SignatureHelp->Value );
196
199
}
197
200
@@ -201,7 +204,8 @@ void ClangdLSPServer::onGoToDefinition(Ctx C,
201
204
Params.textDocument .uri .file ,
202
205
Position{Params.position .line , Params.position .character });
203
206
if (!Items)
204
- return C.replyError (-32602 , llvm::toString (Items.takeError ()));
207
+ return C.replyError (ErrorCode::InvalidParams,
208
+ llvm::toString (Items.takeError ()));
205
209
C.reply (json::ary (Items->Value ));
206
210
}
207
211
@@ -228,7 +232,7 @@ bool ClangdLSPServer::run(std::istream &In) {
228
232
// Set up JSONRPCDispatcher.
229
233
JSONRPCDispatcher Dispatcher (
230
234
[](RequestContext Ctx, llvm::yaml::MappingNode *Params) {
231
- Ctx.replyError (- 32601 , " method not found" );
235
+ Ctx.replyError (ErrorCode::MethodNotFound , " method not found" );
232
236
});
233
237
registerCallbackHandlers (Dispatcher, Out, /* Callbacks=*/ *this );
234
238
0 commit comments