From a45682ed96f18f962ac403419b4d143d59ba5283 Mon Sep 17 00:00:00 2001 From: David Lattimore Date: Wed, 22 Jul 2020 16:23:43 +1000 Subject: 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. --- crates/ra_ssr/src/search.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'crates/ra_ssr/src/search.rs') 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; use ra_syntax::{ast, AstNode, SyntaxNode}; impl<'db> MatchFinder<'db> { - pub(crate) fn slow_scan_node( + pub(crate) fn find_all_matches(&self, matches_out: &mut Vec) { + // FIXME: Use resolved paths in the pattern to find places to search instead of always + // scanning every node. + self.slow_scan(matches_out); + } + + fn slow_scan(&self, matches_out: &mut Vec) { + use ra_db::SourceDatabaseExt; + use ra_ide_db::symbol_index::SymbolsDatabase; + for &root in self.sema.db.local_roots().iter() { + let sr = self.sema.db.source_root(root); + for file_id in sr.iter() { + let file = self.sema.parse(file_id); + let code = file.syntax(); + self.slow_scan_node(code, &None, matches_out); + } + } + } + + fn slow_scan_node( &self, code: &SyntaxNode, restrict_range: &Option, -- cgit v1.2.3