SSR: Explicitly autoderef and ref placeholders as needed

Structured search replace now inserts *, & and &mut in the replacement to match any auto[de]ref in the matched code.
This commit is contained in:
David Lattimore 2020-08-06 07:26:28 +10:00
parent c84f98385a
commit a4a504e132
4 changed files with 222 additions and 25 deletions

View file

@ -21,7 +21,10 @@
// code in the `foo` module, we'll insert just `Bar`.
//
// Inherent method calls should generally be written in UFCS form. e.g. `foo::Bar::baz($s, $a)` will
// match `$s.baz($a)`, provided the method call `baz` resolves to the method `foo::Bar::baz`.
// match `$s.baz($a)`, provided the method call `baz` resolves to the method `foo::Bar::baz`. When a
// placeholder is the receiver of a method call in the search pattern (e.g. `$s.foo()`), but not in
// the replacement template (e.g. `bar($s)`), then *, & and &mut will be added as needed to mirror
// whatever autoderef and autoref was happening implicitly in the matched code.
//
// The scope of the search / replace will be restricted to the current selection if any, otherwise
// it will apply to the whole workspace.