rust/crates/syntax
bors[bot] 34138379b5
Merge #11322
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>
2022-02-01 23:05:28 +00:00
..
fuzz Bump MSRV (1.57) 2021-12-16 01:56:12 +05:00
src Merge #11322 2022-02-01 23:05:28 +00:00
test_data remove fragments from syntax 2021-12-28 17:00:55 +03:00
Cargo.toml Bump MSRV (1.57) 2021-12-16 01:56:12 +05:00