diff options
Diffstat (limited to 'crates/ra_ide/src')
-rw-r--r-- | crates/ra_ide/src/lib.rs | 3 | ||||
-rw-r--r-- | crates/ra_ide/src/ssr.rs | 10 |
2 files changed, 9 insertions, 4 deletions
diff --git a/crates/ra_ide/src/lib.rs b/crates/ra_ide/src/lib.rs index 4c4d9f6fa..0fede0d87 100644 --- a/crates/ra_ide/src/lib.rs +++ b/crates/ra_ide/src/lib.rs | |||
@@ -510,9 +510,10 @@ impl Analysis { | |||
510 | query: &str, | 510 | query: &str, |
511 | parse_only: bool, | 511 | parse_only: bool, |
512 | position: FilePosition, | 512 | position: FilePosition, |
513 | selections: Vec<FileRange>, | ||
513 | ) -> Cancelable<Result<SourceChange, SsrError>> { | 514 | ) -> Cancelable<Result<SourceChange, SsrError>> { |
514 | self.with_db(|db| { | 515 | self.with_db(|db| { |
515 | let edits = ssr::parse_search_replace(query, parse_only, db, position)?; | 516 | let edits = ssr::parse_search_replace(query, parse_only, db, position, selections)?; |
516 | Ok(SourceChange::from(edits)) | 517 | Ok(SourceChange::from(edits)) |
517 | }) | 518 | }) |
518 | } | 519 | } |
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()); |