aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ssr/src/tests.rs
Commit message (Collapse)AuthorAgeFilesLines
* Rename BindPat -> IdentPatAleksey Kladov2020-07-311-1/+1
|
* SSR: Wrap placeholder expansions in parenthesis when necessaryDavid Lattimore2020-07-301-2/+23
| | | | | | | | | 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.
* Merge #5564bors[bot]2020-07-291-17/+79
|\ | | | | | | | | | | | | | | 5564: SSR: Restrict to current selection if any r=davidlattimore a=davidlattimore The selection is also used to avoid unnecessary work, but only to the file level. Further restricting unnecessary work is left for later. Co-authored-by: David Lattimore <[email protected]>
| * SSR: Restrict to current selection if anyDavid Lattimore2020-07-291-17/+79
| | | | | | | | | | The selection is also used to avoid unnecessary work, but only to the file level. Further restricting unnecessary work is left for later.
* | SSR: Don't mix non-path-based rules with path-basedDavid Lattimore2020-07-291-0/+39
|/ | | | If any rules contain paths, then we reject any rules that don't contain paths. Allowing a mix leads to strange semantics, since the path-based rules only match things where the path refers to semantically the same thing, whereas the non-path-based rules could match anything. Specifically, if we have a rule like `foo ==>> bar` we only want to match the `foo` that is in the current scope, not any `foo`. However "foo" can be parsed as a pattern (BIND_PAT -> NAME -> IDENT). Allowing such a rule through would result in renaming everything called `foo` to `bar`. It'd also be slow, since without a path, we'd have to use the slow-scan search mechanism.
* SSR: Fix for path resolution of localsDavid Lattimore2020-07-261-0/+37
| | | | | | | | It seems that Semantics::scope, if given a statement node, won't resolve locals that were defined in the current scope, only in parent scopes. Not sure if this is intended / expected behavior, but we work around it for now by finding another nearby node to use as the scope (e.g. the expression inside the EXPR_STMT).
* SSR: Allow function calls to match method callsDavid Lattimore2020-07-241-0/+58
| | | | | | | | | | | 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: Disable matching within use declarationsDavid Lattimore2020-07-241-0/+23
| | | | | It currently does the wrong thing when the use declaration contains braces.
* SSR: Match paths based on what they resolve toDavid Lattimore2020-07-241-4/+138
| | | | Also render template paths appropriately for their context.
* SSR: Pass current file position through to SSR code.David Lattimore2020-07-241-18/+24
| | | | In a subsequent commit, it will be used for resolving paths.
* SSR: Add a couple of tests for non-recursive searchDavid Lattimore2020-07-241-0/+33
| | | | | These tests already pass, however once we switch to non-recursive search, it'd be easy for these tests to not pass.
* SSR tests: Define all paths needed for templatesDavid Lattimore2020-07-241-26/+76
| | | | | | | In a later commit, paths in templates will be resolved. This allows us to render the path with appropriate qualifiers for its context. Here we prepare for that change by updating existing tests where I'd previously not bothered to define the items that the template referred to.
* Move iteration over all files into the SSR crateDavid Lattimore2020-07-241-18/+22
| | | | 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-2/+2
| | | | | | 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: Use expect! in testsDavid Lattimore2020-07-241-37/+34
|
* SSR: Update tests so that all paths in patterns can be resolvedDavid Lattimore2020-07-031-67/+97
|
* SSR: Improve error reporting when a test failsDavid Lattimore2020-07-031-6/+21
|
* SSR: Add initial support for placeholder constraintsDavid Lattimore2020-07-011-0/+17
|
* Structured search debuggingDavid Lattimore2020-07-011-147/+42
|
* Fix some typosDavid Lattimore2020-06-301-3/+3
|
* Fix handling of whitespace when applying SSR within macro expansions.David Lattimore2020-06-271-0/+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).
* Fix test following change to fixture parsing ↵David Lattimore2020-06-271-1/+11
| | | | (d016cb486738c1ab2574a322924183fa8a870b06)
* SSR: Allow matching within macro callsDavid Lattimore2020-06-271-0/+49
|
* SSR: Allow matching of whole macro callsDavid Lattimore2020-06-221-0/+53
| | | | 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/+496
Part of #3186