mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-14 17:07:26 +00:00
34138379b5
11322: Extract function also extracts comments r=Vannevelj a=Vannevelj Fixes #9011 The difficulty I came across is that the original assist works from the concept of a `ast::StmtList`, a node, but that does not allow me to (easily) represent comments, which are tokens. To combat this, I do a whole bunch of roundtrips: from the `ast::StmtList` I retrieve the `NodeOrToken`s it encompasses. I then cast all `Node` ones back to a `Stmt` so I can apply indentation to it, after which it is again parsed as a `NodeOrToken`. Lastly, I add a new `make::` api that accepts `NodeOrToken` rather than `StmtList` so we can write the comment tokens. Co-authored-by: Jeroen Vannevel <jer_vannevel@outlook.com> |
||
---|---|---|
.. | ||
fuzz | ||
src | ||
test_data | ||
Cargo.toml |