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_ide | |
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_ide')
-rw-r--r-- | crates/ra_ide/src/ssr.rs | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/crates/ra_ide/src/ssr.rs b/crates/ra_ide/src/ssr.rs index b3e9e5dfe..ca7e0ad86 100644 --- a/crates/ra_ide/src/ssr.rs +++ b/crates/ra_ide/src/ssr.rs | |||
@@ -1,5 +1,4 @@ | |||
1 | use ra_db::SourceDatabaseExt; | 1 | use ra_ide_db::RootDatabase; |
2 | use ra_ide_db::{symbol_index::SymbolsDatabase, RootDatabase}; | ||
3 | 2 | ||
4 | use crate::SourceFileEdit; | 3 | use crate::SourceFileEdit; |
5 | use ra_ssr::{MatchFinder, SsrError, SsrRule}; | 4 | use ra_ssr::{MatchFinder, SsrError, SsrRule}; |
@@ -44,20 +43,11 @@ pub fn parse_search_replace( | |||
44 | parse_only: bool, | 43 | parse_only: bool, |
45 | db: &RootDatabase, | 44 | db: &RootDatabase, |
46 | ) -> Result<Vec<SourceFileEdit>, SsrError> { | 45 | ) -> Result<Vec<SourceFileEdit>, SsrError> { |
47 | let mut edits = vec![]; | ||
48 | let rule: SsrRule = rule.parse()?; | 46 | let rule: SsrRule = rule.parse()?; |
49 | if parse_only { | 47 | if parse_only { |
50 | return Ok(edits); | 48 | return Ok(Vec::new()); |
51 | } | 49 | } |
52 | let mut match_finder = MatchFinder::new(db); | 50 | let mut match_finder = MatchFinder::new(db); |
53 | match_finder.add_rule(rule); | 51 | match_finder.add_rule(rule); |
54 | for &root in db.local_roots().iter() { | 52 | Ok(match_finder.edits()) |
55 | let sr = db.source_root(root); | ||
56 | for file_id in sr.iter() { | ||
57 | if let Some(edit) = match_finder.edits_for_file(file_id) { | ||
58 | edits.push(SourceFileEdit { file_id, edit }); | ||
59 | } | ||
60 | } | ||
61 | } | ||
62 | Ok(edits) | ||
63 | } | 53 | } |