aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src
diff options
context:
space:
mode:
authorDavid Lattimore <[email protected]>2020-07-22 06:00:28 +0100
committerDavid Lattimore <[email protected]>2020-07-24 12:34:00 +0100
commit3975952601888d9f77e466c12e8e389748984b33 (patch)
treee599abf34b90be63e091ea78bfa58fe46cf1b81a /crates/ra_ide/src
parent02fc3d50ee4d179cc5a443a790544c2a5e439cb0 (diff)
SSR: Pass current file position through to SSR code.
In a subsequent commit, it will be used for resolving paths.
Diffstat (limited to 'crates/ra_ide/src')
-rw-r--r--crates/ra_ide/src/lib.rs3
-rw-r--r--crates/ra_ide/src/ssr.rs6
2 files changed, 6 insertions, 3 deletions
diff --git a/crates/ra_ide/src/lib.rs b/crates/ra_ide/src/lib.rs
index dc9192d42..7356e947b 100644
--- a/crates/ra_ide/src/lib.rs
+++ b/crates/ra_ide/src/lib.rs
@@ -505,9 +505,10 @@ impl Analysis {
505 &self, 505 &self,
506 query: &str, 506 query: &str,
507 parse_only: bool, 507 parse_only: bool,
508 position: FilePosition,
508 ) -> Cancelable<Result<SourceChange, SsrError>> { 509 ) -> Cancelable<Result<SourceChange, SsrError>> {
509 self.with_db(|db| { 510 self.with_db(|db| {
510 let edits = ssr::parse_search_replace(query, parse_only, db)?; 511 let edits = ssr::parse_search_replace(query, parse_only, db, position)?;
511 Ok(SourceChange::from(edits)) 512 Ok(SourceChange::from(edits))
512 }) 513 })
513 } 514 }
diff --git a/crates/ra_ide/src/ssr.rs b/crates/ra_ide/src/ssr.rs
index ca7e0ad86..3e2705d62 100644
--- a/crates/ra_ide/src/ssr.rs
+++ b/crates/ra_ide/src/ssr.rs
@@ -1,3 +1,4 @@
1use ra_db::FilePosition;
1use ra_ide_db::RootDatabase; 2use ra_ide_db::RootDatabase;
2 3
3use crate::SourceFileEdit; 4use crate::SourceFileEdit;
@@ -42,12 +43,13 @@ pub fn parse_search_replace(
42 rule: &str, 43 rule: &str,
43 parse_only: bool, 44 parse_only: bool,
44 db: &RootDatabase, 45 db: &RootDatabase,
46 position: FilePosition,
45) -> Result<Vec<SourceFileEdit>, SsrError> { 47) -> Result<Vec<SourceFileEdit>, SsrError> {
46 let rule: SsrRule = rule.parse()?; 48 let rule: SsrRule = rule.parse()?;
49 let mut match_finder = MatchFinder::in_context(db, position);
50 match_finder.add_rule(rule);
47 if parse_only { 51 if parse_only {
48 return Ok(Vec::new()); 52 return Ok(Vec::new());
49 } 53 }
50 let mut match_finder = MatchFinder::new(db);
51 match_finder.add_rule(rule);
52 Ok(match_finder.edits()) 54 Ok(match_finder.edits())
53} 55}