aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ssr/src/matching.rs
Commit message (Collapse)AuthorAgeFilesLines
* Rename ra_syntax -> syntaxAleksey Kladov2020-08-121-4/+4
|
* Rename TypeArgList -> GenericArgListAleksey Kladov2020-07-311-2/+2
|
* Rename RecordLit -> RecordExprAleksey Kladov2020-07-301-2/+2
|
* SSR: Restrict to current selection if anyDavid Lattimore2020-07-291-2/+2
| | | | | The selection is also used to avoid unnecessary work, but only to the file level. Further restricting unnecessary work is left for later.
* SSR: Allow function calls to match method callsDavid Lattimore2020-07-241-2/+40
| | | | | | | | | | | This differs from how this used to work before I removed it in that: a) It's only one direction. Function calls in the pattern can match method calls in the code, but not the other way around. b) We now check that the function call in the pattern resolves to the same function as the method call in the code. The lack of (b) was the reason I felt the need to remove the feature before.
* SSR: Match paths based on what they resolve toDavid Lattimore2020-07-241-7/+99
| | | | Also render template paths appropriately for their context.
* SSR: Pass current file position through to SSR code.David Lattimore2020-07-241-2/+2
| | | | In a subsequent commit, it will be used for resolving paths.
* SSR: Refactor to not rely on recursive search for nesting of matchesDavid Lattimore2020-07-241-0/+4
| | | | | | | | | Previously, submatches were handled simply by searching in placeholders for more matches. That only works if we search all nodes in the tree recursively. In a subsequent commit, I intend to make search not always be recursive recursive. This commit prepares for that by finding all matches, even if they overlap, then nesting them and removing overlapping matches.
* Move iteration over all files into the SSR crateDavid Lattimore2020-07-241-7/+8
| | | | The methods `edits_for_file` and `find_matches_in_file` are replaced with just `edits` and `matches`. This simplifies the API a bit, but more importantly it makes it possible in a subsequent commit for SSR to decide to not search all files.
* SSR: Parse template as Rust code.David Lattimore2020-07-241-6/+4
| | | | | | 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-33/+9
| | | | | | | | | | | | | | | | | | | | | | 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.
* SSR: Refactor matching code.David Lattimore2020-07-031-80/+75
| | | | | | Mutable state is now stored in the enum Phase. MatchState, since it now has no mutable state is renamed Matcher. MatchInputs is merged into Matcher
* SSR: Add initial support for placeholder constraintsDavid Lattimore2020-07-011-1/+38
|
* Structured search debuggingDavid Lattimore2020-07-011-6/+4
|
* Fix some typosDavid Lattimore2020-06-301-1/+1
|
* Fix handling of whitespace when applying SSR within macro expansions.David Lattimore2020-06-271-1/+1
| | | | 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 within macro callsDavid Lattimore2020-06-271-1/+3
|
* SSR: Allow matching of whole macro callsDavid Lattimore2020-06-221-4/+101
| | | | 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/+494
Part of #3186