3275: Add Structural Search and Replace doc r=matklad a=adamrk

Addresses the first point of https://github.com/rust-analyzer/rust-analyzer/issues/3186.

Co-authored-by: adamrk <ark.email@gmail.com>
Co-authored-by: Adam Bratschi-Kaye <ark.email@gmail.com>
This commit is contained in:
bors[bot] 2020-02-23 09:49:26 +00:00 committed by GitHub
commit dea1d957e5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -105,6 +105,21 @@ Start `cargo watch` for live error highlighting. Will prompt to install if it's
Stop `cargo watch`.
#### Structural Seach and Replace
Search and replace with named wildcards that will match any expression.
The syntax for a structural search replace command is `<search_pattern> ==>> <replace_pattern>`. A `$<name>:expr` placeholder in the search pattern will match any expression and `$<name>` will reference it in the replacement. Available via the command `rust-analyzer.ssr`.
```rust
// Using structural search replace command [foo($a:expr, $b:expr) ==>> ($a).foo($b)]
// BEFORE
String::from(foo(y + 5, z))
// AFTER
String::from((y + 5).foo(z))
```
### Assists (Code Actions)
Assists, or code actions, are small local refactorings, available in a particular context.