-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Open
Description
We want to migrate all assists to use the new SyntaxEditor/SyntaxFactory abstraction. This will unblock moving to immutable syntax trees (#15710). In doing so, we can choose a flat, contiguous representation that should yield significant performance wins (#17491).
@DropDemBits has outlined the process for migrating most assists:
- Create a
SyntaxFactory, optionally namedmaketo ease migration- Create a
SyntaxEditorusingbuilder.make_editorwith a node from the file- Replace all
make::with make
- Add any missing methods to
syntax::ast::syntax_factory::constructorsas needed- Replace all
ted::witheditor.- After all changes are complete:
editor.add_mappings(make.finish_with_mappings())to add the generated mappingsbuilder.add_file_edits(ctx.file_id(), editor)to add the edits
For assists that use snippets, check the snippet capability, and then useeditor.add_annotationto associate the snippets with the elements.
They have also already migrated the extract_variable assist in #18196 which should be a useful reference.
The assists are located in crates/ide-assists/src/handlers. They should all have tests which you can use to verify that your change works properly by running:
cargo test --package ide-assists -- handlers::<ASSIST>::tests
replacing <ASSIST> with the assist name, e.g., add_braces.
ShoyuVanilla, DropDemBits, ChayimFriedman2, roife, tareknaser and 4 more
Metadata
Metadata
Assignees
Labels
No labels