Stream: t-compiler/rust-analyzer

Topic: Assist Framework


Yoshua Wuyts (Feb 08 2021 at 12:30, on Zulip):

Heya; last Friday I hacked some on RA and had a lot of fun. I ended up copying and then refactoring several utility functions from other assists. E.g. in assists/src/utils.rs: find_impl_block and find_struct_impl.

I've seen other utilities in the assists lib float around, such as: add_trait_assoc_items_to_impl. These three all seem closely related, and it feels like we could create some structures to for example target and manipulate impl blocks. I suspect that with a bit of effort we could create structures which would make it possible to author and update assists more quickly and accurately.

I was wondering what the current state of thinking on this was, and whether it'd be useful to draft a quick design for this?

Yoshua Wuyts (Feb 08 2021 at 12:31, on Zulip):

One piece of functionality I'd like to add for example is a way to both "add a method to the start of an impl block" and "add a method to the end of an impl block". Right now the "add matches method" assist pushes new methods to the start of impl blocks, which doesn't feel right.

matklad (Feb 08 2021 at 12:34, on Zulip):

Note that https://github.com/rust-analyzer/rust-analyzer/pull/7498/ will change in a fundamental way how we write asssists. In particular, it should provide way better composability

matklad (Feb 08 2021 at 12:35, on Zulip):

The TL;DR is that the syntax tree becomes mutable-ish, so that my_impl.add_method(make::...) will just work

matklad (Feb 08 2021 at 12:36, on Zulip):

No eta on how that lands though :)

matklad (Feb 08 2021 at 12:37, on Zulip):

Which is to say: yes, long term we need some assist framework. But at the moment the churn rate of the undrelying abstraction is high, so we don't try to go far beyound the utils module just yet.

Yoshua Wuyts (Feb 08 2021 at 12:38, on Zulip):

Cool! -- that sounds really good, and I'm glad I asked ^^

Yoshua Wuyts (Feb 08 2021 at 12:40, on Zulip):

just seeing rowan for the first time now; that's incredibly exciting

Last update: Jul 28 2021 at 05:15UTC