Stream: t-compiler/rust-analyzer

Topic: Forging requests


ivan770 (Mar 14 2021 at 14:30, on Zulip):

While trying to work on https://github.com/rust-analyzer/rust-analyzer/issues/6823 I ran into a trouble of forging requests without modifying TS extension part of RA. Is there any way to invoke arbitrary methods from VS Code by just passing custom JSON?

matklad (Mar 14 2021 at 14:31, on Zulip):

I don't think so. But I think that feature requires custom TS anyway?

ivan770 (Mar 14 2021 at 14:32, on Zulip):

Yep. But I decided to start from Rust part, and only then work on TS

matklad (Mar 14 2021 at 14:35, on Zulip):

For the rust part, I'd go with just writing unit-tests in the IDE module (how, eg, join_lines work). When integrating with LSP, I don't think there's an easier way then just writing both the rust and the TS parts together. On the bright side, the LSP part should be mostly trivial, so it often just writes itself from the definitions of request/response types.

ivan770 (Mar 16 2021 at 08:27, on Zulip):

I guess Rust part is done, and tests are passing, though I'm not sure about chosen API. Is it ok to just ask for a cursor position and direction? image.png

matklad (Mar 16 2021 at 08:30, on Zulip):

Seem right overall

ivan770 (Mar 16 2021 at 08:30, on Zulip):

On VS Code side this can be implemented as two different commands, so that user bindings are possible

matklad (Mar 16 2021 at 08:30, on Zulip):

You probably want lsp_types::TextDocumentEdit instead of just a vector of edits

matklad (Mar 16 2021 at 08:31, on Zulip):

And I think it's best to use Range rather than Position for input, such that we can extend this to multiple items in the futuer

ivan770 (Mar 16 2021 at 08:32, on Zulip):

Got it. Thanks!

ivan770 (Mar 16 2021 at 15:18, on Zulip):

Are there any issues with CI? Cross is failing to compile, other ones (and my local build) are successful. https://github.com/rust-analyzer/rust-analyzer/pull/8054/checks

matklad (Mar 16 2021 at 15:22, on Zulip):

needs a rebase(/

matklad (Mar 16 2021 at 15:22, on Zulip):

?

Laurențiu (Mar 16 2021 at 15:23, on Zulip):

I can't reproduce locally with cargo check --all-targets --target powerpc-unknown-linux-gnu, but rebasing might be a good idea

ivan770 (Mar 16 2021 at 15:31, on Zulip):

Yep, looks like that helped. Thanks.

ivan770 (Mar 19 2021 at 14:56, on Zulip):

I guess item movers are ready for review - https://github.com/rust-analyzer/rust-analyzer/pull/8054

Last update: Jul 27 2021 at 21:45UTC