aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src/lib.rs
diff options
context:
space:
mode:
authorMikhail Modin <[email protected]>2020-02-10 22:45:38 +0000
committerMikhail Modin <[email protected]>2020-02-14 21:45:42 +0000
commitf8f454ab5c19c6e7d91b3a4e6bb63fb9bf5f2673 (patch)
treee80fbf31a2f69916c86b5569da4f673e7818d8ec /crates/ra_ide/src/lib.rs
parent6fb36dfdcb91f67c28f51e51514ebe420ec3aa22 (diff)
Init implementation of structural search replace
Diffstat (limited to 'crates/ra_ide/src/lib.rs')
-rw-r--r--crates/ra_ide/src/lib.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/crates/ra_ide/src/lib.rs b/crates/ra_ide/src/lib.rs
index 689921f3f..dfd191e42 100644
--- a/crates/ra_ide/src/lib.rs
+++ b/crates/ra_ide/src/lib.rs
@@ -37,6 +37,7 @@ mod display;
37mod inlay_hints; 37mod inlay_hints;
38mod expand; 38mod expand;
39mod expand_macro; 39mod expand_macro;
40mod ssr;
40 41
41#[cfg(test)] 42#[cfg(test)]
42mod marks; 43mod marks;
@@ -73,6 +74,7 @@ pub use crate::{
73 }, 74 },
74 runnables::{Runnable, RunnableKind}, 75 runnables::{Runnable, RunnableKind},
75 source_change::{FileSystemEdit, SourceChange, SourceFileEdit}, 76 source_change::{FileSystemEdit, SourceChange, SourceFileEdit},
77 ssr::SsrError,
76 syntax_highlighting::HighlightedRange, 78 syntax_highlighting::HighlightedRange,
77}; 79};
78 80
@@ -464,6 +466,16 @@ impl Analysis {
464 self.with_db(|db| references::rename(db, position, new_name)) 466 self.with_db(|db| references::rename(db, position, new_name))
465 } 467 }
466 468
469 pub fn structural_search_replace(
470 &self,
471 query: &str,
472 ) -> Cancelable<Result<SourceChange, SsrError>> {
473 self.with_db(|db| {
474 let edits = ssr::parse_search_replace(query, db)?;
475 Ok(SourceChange::source_file_edits("ssr", edits))
476 })
477 }
478
467 /// Performs an operation on that may be Canceled. 479 /// Performs an operation on that may be Canceled.
468 fn with_db<F: FnOnce(&RootDatabase) -> T + std::panic::UnwindSafe, T>( 480 fn with_db<F: FnOnce(&RootDatabase) -> T + std::panic::UnwindSafe, T>(
469 &self, 481 &self,