mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-11-02 04:48:13 +00:00
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> |
||
|---|---|---|
| .. | ||
| ast | ||
| parsing | ||
| tests | ||
| validation | ||
| algo.rs | ||
| ast.rs | ||
| display.rs | ||
| fuzz.rs | ||
| hacks.rs | ||
| lib.rs | ||
| parsing.rs | ||
| ptr.rs | ||
| syntax_error.rs | ||
| syntax_node.rs | ||
| ted.rs | ||
| tests.rs | ||
| token_text.rs | ||
| utils.rs | ||
| validation.rs | ||