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
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?
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.
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
The TL;DR is that the syntax tree becomes mutable-ish, so that
my_impl.add_method(make::...) will just work
No eta on how that lands though :)
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.
Cool! -- that sounds really good, and I'm glad I asked ^^
rowan for the first time now; that's incredibly exciting