diff options
Diffstat (limited to 'crates/ra_ide/src/ssr.rs')
-rw-r--r-- | crates/ra_ide/src/ssr.rs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/crates/ra_ide/src/ssr.rs b/crates/ra_ide/src/ssr.rs index 95d8f79b8..4348b43be 100644 --- a/crates/ra_ide/src/ssr.rs +++ b/crates/ra_ide/src/ssr.rs | |||
@@ -1,4 +1,4 @@ | |||
1 | use ra_db::FilePosition; | 1 | use ra_db::{FilePosition, FileRange}; |
2 | use ra_ide_db::RootDatabase; | 2 | use ra_ide_db::RootDatabase; |
3 | 3 | ||
4 | use crate::SourceFileEdit; | 4 | use crate::SourceFileEdit; |
@@ -24,6 +24,9 @@ use ra_ssr::{MatchFinder, SsrError, SsrRule}; | |||
24 | // Method calls should generally be written in UFCS form. e.g. `foo::Bar::baz($s, $a)` will match | 24 | // Method calls should generally be written in UFCS form. e.g. `foo::Bar::baz($s, $a)` will match |
25 | // `$s.baz($a)`, provided the method call `baz` resolves to the method `foo::Bar::baz`. | 25 | // `$s.baz($a)`, provided the method call `baz` resolves to the method `foo::Bar::baz`. |
26 | // | 26 | // |
27 | // The scope of the search / replace will be restricted to the current selection if any, otherwise | ||
28 | // it will apply to the whole workspace. | ||
29 | // | ||
27 | // Placeholders may be given constraints by writing them as `${<name>:<constraint1>:<constraint2>...}`. | 30 | // Placeholders may be given constraints by writing them as `${<name>:<constraint1>:<constraint2>...}`. |
28 | // | 31 | // |
29 | // Supported constraints: | 32 | // Supported constraints: |
@@ -56,10 +59,11 @@ pub fn parse_search_replace( | |||
56 | rule: &str, | 59 | rule: &str, |
57 | parse_only: bool, | 60 | parse_only: bool, |
58 | db: &RootDatabase, | 61 | db: &RootDatabase, |
59 | position: FilePosition, | 62 | resolve_context: FilePosition, |
63 | selections: Vec<FileRange>, | ||
60 | ) -> Result<Vec<SourceFileEdit>, SsrError> { | 64 | ) -> Result<Vec<SourceFileEdit>, SsrError> { |
61 | let rule: SsrRule = rule.parse()?; | 65 | let rule: SsrRule = rule.parse()?; |
62 | let mut match_finder = MatchFinder::in_context(db, position); | 66 | let mut match_finder = MatchFinder::in_context(db, resolve_context, selections); |
63 | match_finder.add_rule(rule)?; | 67 | match_finder.add_rule(rule)?; |
64 | if parse_only { | 68 | if parse_only { |
65 | return Ok(Vec::new()); | 69 | return Ok(Vec::new()); |