mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-13 21:54:42 +00:00
Merge #3275
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:
commit
dea1d957e5
1 changed files with 15 additions and 0 deletions
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue