This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Send the correct error code when cancelling requests.
ClosedPublic

Authored by sammccall on Apr 11 2020, 9:20 AM.

Details

Summary

I couldn't quite bring myself to make Cancellation depend on LSP ErrorCode.
Magic numbers instead...

Diff Detail

Event Timeline

sammccall created this revision.Apr 11 2020, 9:20 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 11 2020, 9:20 AM
kadircet accepted this revision.Apr 12 2020, 1:35 AM

Thanks for remembering this :D LGTM!

clang-tools-extra/clangd/JSONTransport.cpp
28

Maybe static_cast<ErrorCode>(C.Reason) instead of casting cases.

I know the reason is not necessarily LSP specific, but we seem to be defaulting to ErrorCode::RequestCancelled anyways.

29

please fix

This revision is now accepted and ready to land.Apr 12 2020, 1:35 AM
sammccall marked an inline comment as done.Apr 13 2020, 10:33 AM
sammccall added inline comments.
clang-tools-extra/clangd/JSONTransport.cpp
28

Sadly this is UB if the value isn't an element of the enum (or in its range, or something). Whereas casting the cases leaves the code valid for arbitrary integers.

This revision was automatically updated to reflect the committed changes.