ilya-biryukov created this revision. ilya-biryukov added a reviewer: sammccall. Herald added subscribers: kadircet, arphaman, jkorous, MaskRay. Herald added a project: clang.
We currently return 'UnknownErrorCode' and it causes `coc.nvim` to show an error message to the user, which we want to avoid. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D62999 Files: clang-tools-extra/clangd/ClangdLSPServer.cpp clang-tools-extra/clangd/test/completion-auto-trigger.test Index: clang-tools-extra/clangd/test/completion-auto-trigger.test =================================================================== --- clang-tools-extra/clangd/test/completion-auto-trigger.test +++ clang-tools-extra/clangd/test/completion-auto-trigger.test @@ -5,7 +5,7 @@ --- {"jsonrpc":"2.0","id":1,"method":"textDocument/completion","params":{"textDocument":{"uri":"test:///main.cpp"},"position":{"line":2,"character":9},"context":{"triggerKind":2,"triggerCharacter":">"}}} # CHECK: "error": { -# CHECK-NEXT: "code": -32001, +# CHECK-NEXT: "code": -32800, # CHECK-NEXT: "message": "ignored auto-triggered completion, preceding char did not match" # CHECK-NEXT: }, # CHECK-NEXT: "id": 1, @@ -65,7 +65,7 @@ --- {"jsonrpc":"2.0","id":3,"method":"textDocument/completion","params":{"textDocument":{"uri":"test:///main.cpp"},"position":{"line":5,"character":9},"context":{"triggerKind":2,"triggerCharacter":":"}}} # CHECK: "error": { -# CHECK-NEXT: "code": -32001, +# CHECK-NEXT: "code": -32800, # CHECK-NEXT: "message": "ignored auto-triggered completion, preceding char did not match" # CHECK-NEXT: }, # CHECK-NEXT: "id": 3, Index: clang-tools-extra/clangd/ClangdLSPServer.cpp =================================================================== --- clang-tools-extra/clangd/ClangdLSPServer.cpp +++ clang-tools-extra/clangd/ClangdLSPServer.cpp @@ -25,16 +25,6 @@ namespace clang { namespace clangd { namespace { -class IgnoreCompletionError : public llvm::ErrorInfo<CancelledError> { -public: - void log(llvm::raw_ostream &OS) const override { - OS << "ignored auto-triggered completion, preceding char did not match"; - } - std::error_code convertToErrorCode() const override { - return std::make_error_code(std::errc::operation_canceled); - } -}; - /// Transforms a tweak into a code action that would apply it if executed. /// EXPECTS: T.prepare() was called and returned true. CodeAction toCodeAction(const ClangdServer::TweakRef &T, const URIForFile &File, @@ -739,7 +729,9 @@ void ClangdLSPServer::onCompletion(const CompletionParams &Params, Callback<CompletionList> Reply) { if (!shouldRunCompletion(Params)) - return Reply(llvm::make_error<IgnoreCompletionError>()); + return Reply(llvm::make_error<LSPError>( + "ignored auto-triggered completion, preceding char did not match", + ErrorCode::RequestCancelled)); Server->codeComplete(Params.textDocument.uri.file(), Params.position, CCOpts, Bind( [this](decltype(Reply) Reply,
Index: clang-tools-extra/clangd/test/completion-auto-trigger.test =================================================================== --- clang-tools-extra/clangd/test/completion-auto-trigger.test +++ clang-tools-extra/clangd/test/completion-auto-trigger.test @@ -5,7 +5,7 @@ --- {"jsonrpc":"2.0","id":1,"method":"textDocument/completion","params":{"textDocument":{"uri":"test:///main.cpp"},"position":{"line":2,"character":9},"context":{"triggerKind":2,"triggerCharacter":">"}}} # CHECK: "error": { -# CHECK-NEXT: "code": -32001, +# CHECK-NEXT: "code": -32800, # CHECK-NEXT: "message": "ignored auto-triggered completion, preceding char did not match" # CHECK-NEXT: }, # CHECK-NEXT: "id": 1, @@ -65,7 +65,7 @@ --- {"jsonrpc":"2.0","id":3,"method":"textDocument/completion","params":{"textDocument":{"uri":"test:///main.cpp"},"position":{"line":5,"character":9},"context":{"triggerKind":2,"triggerCharacter":":"}}} # CHECK: "error": { -# CHECK-NEXT: "code": -32001, +# CHECK-NEXT: "code": -32800, # CHECK-NEXT: "message": "ignored auto-triggered completion, preceding char did not match" # CHECK-NEXT: }, # CHECK-NEXT: "id": 3, Index: clang-tools-extra/clangd/ClangdLSPServer.cpp =================================================================== --- clang-tools-extra/clangd/ClangdLSPServer.cpp +++ clang-tools-extra/clangd/ClangdLSPServer.cpp @@ -25,16 +25,6 @@ namespace clang { namespace clangd { namespace { -class IgnoreCompletionError : public llvm::ErrorInfo<CancelledError> { -public: - void log(llvm::raw_ostream &OS) const override { - OS << "ignored auto-triggered completion, preceding char did not match"; - } - std::error_code convertToErrorCode() const override { - return std::make_error_code(std::errc::operation_canceled); - } -}; - /// Transforms a tweak into a code action that would apply it if executed. /// EXPECTS: T.prepare() was called and returned true. CodeAction toCodeAction(const ClangdServer::TweakRef &T, const URIForFile &File, @@ -739,7 +729,9 @@ void ClangdLSPServer::onCompletion(const CompletionParams &Params, Callback<CompletionList> Reply) { if (!shouldRunCompletion(Params)) - return Reply(llvm::make_error<IgnoreCompletionError>()); + return Reply(llvm::make_error<LSPError>( + "ignored auto-triggered completion, preceding char did not match", + ErrorCode::RequestCancelled)); Server->codeComplete(Params.textDocument.uri.file(), Params.position, CCOpts, Bind( [this](decltype(Reply) Reply,
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits