Skip to content

Commit ae3abd6

Browse files
committed
Rename ra_ssr -> ssr
1 parent bb5c189 commit ae3abd6

File tree

18 files changed

+95
-110
lines changed

18 files changed

+95
-110
lines changed

Cargo.lock

Lines changed: 16 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/ra_ide/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ cfg = { path = "../cfg" }
2929
profile = { path = "../profile" }
3030
test_utils = { path = "../test_utils" }
3131
ra_assists = { path = "../ra_assists" }
32-
ra_ssr = { path = "../ra_ssr" }
32+
ssr = { path = "../ssr" }
3333

3434
# ra_ide should depend only on the top-level `hir` package. if you need
3535
# something from some `hir_xxx` subpackage, reexport the API via `hir`.

crates/ra_ide/src/lib.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ mod matching_brace;
3939
mod parent_module;
4040
mod references;
4141
mod runnables;
42-
mod ssr;
4342
mod status;
4443
mod syntax_highlighting;
4544
mod syntax_tree;
@@ -95,7 +94,7 @@ pub use ide_db::{
9594
RootDatabase,
9695
};
9796
pub use ra_assists::{Assist, AssistConfig, AssistId, AssistKind, ResolvedAssist};
98-
pub use ra_ssr::SsrError;
97+
pub use ssr::SsrError;
9998
pub use text_edit::{Indel, TextEdit};
10099

101100
pub type Cancelable<T> = Result<T, Canceled>;
@@ -515,20 +514,23 @@ impl Analysis {
515514
&self,
516515
query: &str,
517516
parse_only: bool,
518-
position: FilePosition,
517+
resolve_context: FilePosition,
519518
selections: Vec<FileRange>,
520519
) -> Cancelable<Result<SourceChange, SsrError>> {
521520
self.with_db(|db| {
522-
let edits = ssr::parse_search_replace(query, parse_only, db, position, selections)?;
521+
let rule: ssr::SsrRule = query.parse()?;
522+
let mut match_finder = ssr::MatchFinder::in_context(db, resolve_context, selections);
523+
match_finder.add_rule(rule)?;
524+
let edits = if parse_only { Vec::new() } else { match_finder.edits() };
523525
Ok(SourceChange::from(edits))
524526
})
525527
}
526528

527529
/// Performs an operation on that may be Canceled.
528-
fn with_db<F: FnOnce(&RootDatabase) -> T + std::panic::UnwindSafe, T>(
529-
&self,
530-
f: F,
531-
) -> Cancelable<T> {
530+
fn with_db<F, T>(&self, f: F) -> Cancelable<T>
531+
where
532+
F: FnOnce(&RootDatabase) -> T + std::panic::UnwindSafe,
533+
{
532534
self.db.catch_canceled(f)
533535
}
534536
}

crates/ra_ide/src/ssr.rs

Lines changed: 0 additions & 72 deletions
This file was deleted.

crates/rust-analyzer/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ toolchain = { path = "../toolchain" }
4848
# This should only be used in CLI
4949
base_db = { path = "../base_db" }
5050
ide_db = { path = "../ide_db" }
51-
ra_ssr = { path = "../ra_ssr" }
51+
ssr = { path = "../ssr" }
5252
hir = { path = "../hir" }
5353
hir_def = { path = "../hir_def" }
5454
hir_ty = { path = "../hir_ty" }

crates/rust-analyzer/src/bin/args.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ use std::{env, fmt::Write, path::PathBuf};
77

88
use anyhow::{bail, Result};
99
use pico_args::Arguments;
10-
use ra_ssr::{SsrPattern, SsrRule};
1110
use rust_analyzer::cli::{AnalysisStatsCmd, BenchCmd, BenchWhat, Position, Verbosity};
11+
use ssr::{SsrPattern, SsrRule};
1212
use vfs::AbsPathBuf;
1313

1414
pub(crate) struct Args {

crates/rust-analyzer/src/cli.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ use anyhow::Result;
1313
use ra_ide::Analysis;
1414
use syntax::{AstNode, SourceFile};
1515

16-
pub use analysis_bench::{BenchCmd, BenchWhat, Position};
17-
pub use analysis_stats::AnalysisStatsCmd;
18-
pub use diagnostics::diagnostics;
19-
pub use load_cargo::load_cargo;
20-
pub use ssr::{apply_ssr_rules, search_for_patterns};
16+
pub use self::{
17+
analysis_bench::{BenchCmd, BenchWhat, Position},
18+
analysis_stats::AnalysisStatsCmd,
19+
diagnostics::diagnostics,
20+
load_cargo::load_cargo,
21+
ssr::{apply_ssr_rules, search_for_patterns},
22+
};
2123

2224
#[derive(Clone, Copy)]
2325
pub enum Verbosity {

crates/rust-analyzer/src/cli/ssr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Applies structured search replace rules from the command line.
22
33
use crate::cli::{load_cargo::load_cargo, Result};
4-
use ra_ssr::{MatchFinder, SsrPattern, SsrRule};
4+
use ssr::{MatchFinder, SsrPattern, SsrRule};
55

66
pub fn apply_ssr_rules(rules: Vec<SsrRule>) -> Result<()> {
77
use base_db::SourceDatabaseExt;

crates/ra_ssr/Cargo.toml renamed to crates/ssr/Cargo.toml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
[package]
2-
edition = "2018"
3-
name = "ra_ssr"
2+
name = "ssr"
43
version = "0.1.0"
5-
authors = ["rust-analyzer developers"]
6-
license = "MIT OR Apache-2.0"
74
description = "Structural search and replace of Rust code"
5+
license = "MIT OR Apache-2.0"
86
repository = "https://github.com/rust-analyzer/rust-analyzer"
7+
authors = ["rust-analyzer developers"]
8+
edition = "2018"
99

1010
[lib]
1111
doctest = false
1212

1313
[dependencies]
14+
rustc-hash = "1.1.0"
15+
1416
text_edit = { path = "../text_edit" }
1517
syntax = { path = "../syntax" }
1618
base_db = { path = "../base_db" }
1719
ide_db = { path = "../ide_db" }
1820
hir = { path = "../hir" }
19-
rustc-hash = "1.1.0"
2021
test_utils = { path = "../test_utils" }
2122

2223
[dev-dependencies]
File renamed without changes.

0 commit comments

Comments
 (0)