aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ssr/src/replacing.rs
Commit message (Collapse)AuthorAgeFilesLines
* SSR: Wrap placeholder expansions in parenthesis when necessaryDavid Lattimore2020-07-301-18/+88
| | | | | | | | | e.g. `foo($a) ==> $a.to_string()` should produce `(1 + 2).to_string()` not `1 + 2.to_string()` We don't yet try to determine if the whole replacement needs to be wrapped in parenthesis. That's harder and I think perhaps less often an issue.
* SSR: Match paths based on what they resolve toDavid Lattimore2020-07-241-10/+30
| | | | Also render template paths appropriately for their context.
* SSR: Parse template as Rust code.David Lattimore2020-07-241-36/+70
| | | | | | This is in preparation for a subsequent commit where we add special handling for paths in the template, allowing them to be qualified differently in different contexts.
* SSR: Change the way rules are stored internally.David Lattimore2020-07-241-1/+5
| | | | | | | | | | | | | | | | | | | | | | Previously we had: - Multiple rules - Each rule had its pattern parsed as an expression, path etc This meant that there were two levels at which there could be multiple rules. Now we just have multiple rules. If a pattern can parse as more than one kind of thing, then they get stored as multiple separate rules. We also now don't have separate fields for the different kinds of things that a pattern can parse as. This makes adding new kinds of things simpler. Previously, add_search_pattern would construct a rule with a dummy replacement. Now the replacement is an Option. This is slightly cleaner and also opens the way for parsing the replacement template as the same kind of thing as the search pattern.
* Structured search debuggingDavid Lattimore2020-07-011-2/+4
|
* Fix handling of whitespace when applying SSR within macro expansions.David Lattimore2020-06-271-16/+17
| | | | I originally did replacement by passing in the full file text. Then as some point I thought I could do without it. Turns out calling .text() on a node coming from a macro expansion isn't a great idea, especially when you then try and use ranges from the original source to cut that text. The test I added here actually panics without the rest of this change (sorry I didn't notice sooner).
* SSR: Allow matching of whole macro callsDavid Lattimore2020-06-221-1/+9
| | | | Matching within macro calls is to come later and matching of macro calls within macro calls later still.
* Allow SSR to match type references, items, paths and patternsDavid Lattimore2020-06-221-0/+55
Part of #3186