rust-analyzer/crates/ssr/src
Marijn Suijten d33edb4e9c ssr: Allow replacing expressions with statements
Now that statements can be matched and replaced (#6587) some usecases
require expressions to be replaced with statements as well. This happens
when something that can ambiguously be an expression or statement like
`if` and loop blocks appear in the last position of a block, as trailing
expression. In this case a replacement pattern of the form `if
foo(){$a();}==>>$a();` will only substitute `if` blocks in the list of
statements but not if they (implicitly) end up in the trailing
expression, where they are not wrapped by an EXPR_STMT (but the pattern
and template are, as parsing only succeeds for the `stmt ==>> stmt`
case).

Instead of adding two rules that match an expression - and emit
duplicate matching errors - allow the template for expressions to be a
statement if it fails to parse as an expression.
2021-01-04 10:55:09 +01:00
..
errors.rs Rename ra_ssr -> ssr 2020-08-13 17:02:44 +02:00
lib.rs Re-export base_db from ide_db 2020-10-24 11:39:57 +03:00
matching.rs Remove some unneeded string allocations 2020-12-31 10:13:14 +01:00
nester.rs Rename ra_ssr -> ssr 2020-08-13 17:02:44 +02:00
parsing.rs ssr: Allow replacing expressions with statements 2021-01-04 10:55:09 +01:00
replacing.rs ⬆️ ungrammar 2020-08-21 19:14:05 +02:00
resolving.rs Re-export base_db from ide_db 2020-10-24 11:39:57 +03:00
search.rs Re-export base_db from ide_db 2020-10-24 11:39:57 +03:00
tests.rs ssr: Allow replacing expressions with statements 2021-01-04 10:55:09 +01:00