-
Notifications
You must be signed in to change notification settings - Fork 1.7k
SSR internal refactorings #5197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
davidlattimore
commented
Jul 3, 2020
- Extract error code out to a separate module
- Improve error reporting when a test fails
- Refactor matching code
- Update tests so that all paths in search patterns can be resolved
bors d+ |
✌️ davidlattimore can now approve this pull request. To approve and merge a pull request, simply reply with |
FYI, SSR just saved me a bunch of time (well, if I exlclude gif recording and twitter bragging :) ) https://twitter.com/rust_analyzer/status/1279045923373559813 |
btw, I've fond SSR to take non-trivial amount of time for rust-analyzer repository. i think we can make it faster by using the following tricks (see
|
This is to make reusing it outside of parsing easier in a subsequent change.
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
c5079a8
to
a354e5b
Compare
In terms of speed, I’ve been working on matching paths by resolving all paths in the pattern. Then when a path is encountered in the code we'd resolve that path and check if it resolved to the same thing as the corresponding path in the pattern. This means that we need a scope in which to resolve paths in the pattern. Initially I was thinking the “root”, but since there can be multiple roots, I eventually concluded that it might make sense to instead use the scope that the user was in when they invoked SSR. i.e. pass through a FilePosition. This means that the pattern should be able to refer to private paths in the current scope, or even local variables in the current scope. Once we’ve resolved each path in the pattern, I was thinking I’d try to leverage the existing code in
This should I think make things pretty fast and would reuse the One thing I've been thinking about is how to handle situations like I think we probably in addition to leveraging paths, we need some way to be able to restrict the scope of the search, even when it only contains public paths (or contains no paths). I guess common scopes might be the current file, the current crate or everything. Not sure of the best way. We could have separate "SSR in current file", "SSR in crate" options. That doesn't feel like it scales very well. Another option would be to allow some marker in the rule. e.g. |
bors r+ |