mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 06:11:35 +00:00
Init implementation of structural search replace
This commit is contained in:
parent
6fb36dfdcb
commit
f8f454ab5c
10 changed files with 399 additions and 1 deletions
|
@ -37,6 +37,7 @@ mod display;
|
|||
mod inlay_hints;
|
||||
mod expand;
|
||||
mod expand_macro;
|
||||
mod ssr;
|
||||
|
||||
#[cfg(test)]
|
||||
mod marks;
|
||||
|
@ -73,6 +74,7 @@ pub use crate::{
|
|||
},
|
||||
runnables::{Runnable, RunnableKind},
|
||||
source_change::{FileSystemEdit, SourceChange, SourceFileEdit},
|
||||
ssr::SsrError,
|
||||
syntax_highlighting::HighlightedRange,
|
||||
};
|
||||
|
||||
|
@ -464,6 +466,16 @@ impl Analysis {
|
|||
self.with_db(|db| references::rename(db, position, new_name))
|
||||
}
|
||||
|
||||
pub fn structural_search_replace(
|
||||
&self,
|
||||
query: &str,
|
||||
) -> Cancelable<Result<SourceChange, SsrError>> {
|
||||
self.with_db(|db| {
|
||||
let edits = ssr::parse_search_replace(query, db)?;
|
||||
Ok(SourceChange::source_file_edits("ssr", edits))
|
||||
})
|
||||
}
|
||||
|
||||
/// Performs an operation on that may be Canceled.
|
||||
fn with_db<F: FnOnce(&RootDatabase) -> T + std::panic::UnwindSafe, T>(
|
||||
&self,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue