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> |
||
---|---|---|
.. | ||
base_db | ||
cfg | ||
flycheck | ||
hir | ||
hir_def | ||
hir_expand | ||
hir_ty | ||
ide | ||
ide_assists | ||
ide_completion | ||
ide_db | ||
ide_diagnostics | ||
ide_ssr | ||
limit | ||
mbe | ||
parser | ||
paths | ||
proc_macro_api | ||
proc_macro_srv | ||
proc_macro_test | ||
profile | ||
project_model | ||
rust-analyzer | ||
sourcegen | ||
stdx | ||
syntax | ||
test_utils | ||
text_edit | ||
toolchain | ||
tt | ||
vfs | ||
vfs-notify |