rust-analyzer/crates/syntax/src
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
..
ast Merge #11322 2022-02-01 23:05:28 +00:00
parsing dead code 2021-12-28 19:13:30 +03:00
tests Allow doc comments on all Items 2022-01-08 15:27:48 +01:00
validation Add semicolons for consistency 2021-10-03 23:39:43 +11:00
algo.rs Make selections in assists with trailing/leading whitespace more forgiving 2021-10-12 14:41:59 +02:00
ast.rs Reduce allocations in attribute collection 2022-01-30 22:18:32 +01:00
display.rs Fully render type alias completions from hir 2021-12-21 16:36:23 +01:00
fuzz.rs Add more docs 2021-05-22 16:53:47 +03:00
hacks.rs dead code 2021-12-28 19:13:30 +03:00
lib.rs Make more precise range macro upmapping 2022-01-31 15:53:44 +01:00
parsing.rs dead code 2021-12-28 19:13:30 +03:00
ptr.rs Migrate to SyntaxNodePtr in new rowan 2021-12-29 23:48:53 -08:00
syntax_error.rs Rename ra_syntax -> syntax 2020-08-12 18:30:53 +02:00
syntax_node.rs internal: replace TreeSink with a data structure 2021-12-25 22:02:26 +03:00
ted.rs Add semicolons for consistency 2021-10-03 23:39:43 +11:00
tests.rs remove fragments from syntax 2021-12-28 17:00:55 +03:00
token_text.rs Imrove fn name computation in Generate function 2021-09-16 21:03:37 +05:00
utils.rs Better strip turbofishes 2021-03-08 23:59:39 +02:00
validation.rs match_ast! takes a pattern to allow underscore usage 2021-12-14 12:44:31 +01:00