diff options
author | David Lattimore <[email protected]> | 2020-07-22 07:23:43 +0100 |
---|---|---|
committer | David Lattimore <[email protected]> | 2020-07-24 12:34:00 +0100 |
commit | a45682ed96f18f962ac403419b4d143d59ba5283 (patch) | |
tree | 5f2178b2957b2e7cfddac94ec1748edb3dd19f10 /crates/ra_ssr/src/search.rs | |
parent | 13f901f636846e330699a4414059591ec2e67cd1 (diff) |
Move iteration over all files into the SSR crate
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.
Diffstat (limited to 'crates/ra_ssr/src/search.rs')
-rw-r--r-- | crates/ra_ssr/src/search.rs | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/crates/ra_ssr/src/search.rs b/crates/ra_ssr/src/search.rs index 6f21452ac..ec3addcf8 100644 --- a/crates/ra_ssr/src/search.rs +++ b/crates/ra_ssr/src/search.rs | |||
@@ -5,7 +5,26 @@ use ra_db::FileRange; | |||
5 | use ra_syntax::{ast, AstNode, SyntaxNode}; | 5 | use ra_syntax::{ast, AstNode, SyntaxNode}; |
6 | 6 | ||
7 | impl<'db> MatchFinder<'db> { | 7 | impl<'db> MatchFinder<'db> { |
8 | pub(crate) fn slow_scan_node( | 8 | pub(crate) fn find_all_matches(&self, matches_out: &mut Vec<Match>) { |
9 | // FIXME: Use resolved paths in the pattern to find places to search instead of always | ||
10 | // scanning every node. | ||
11 | self.slow_scan(matches_out); | ||
12 | } | ||
13 | |||
14 | fn slow_scan(&self, matches_out: &mut Vec<Match>) { | ||
15 | use ra_db::SourceDatabaseExt; | ||
16 | use ra_ide_db::symbol_index::SymbolsDatabase; | ||
17 | for &root in self.sema.db.local_roots().iter() { | ||
18 | let sr = self.sema.db.source_root(root); | ||
19 | for file_id in sr.iter() { | ||
20 | let file = self.sema.parse(file_id); | ||
21 | let code = file.syntax(); | ||
22 | self.slow_scan_node(code, &None, matches_out); | ||
23 | } | ||
24 | } | ||
25 | } | ||
26 | |||
27 | fn slow_scan_node( | ||
9 | &self, | 28 | &self, |
10 | code: &SyntaxNode, | 29 | code: &SyntaxNode, |
11 | restrict_range: &Option<FileRange>, | 30 | restrict_range: &Option<FileRange>, |