diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-08-13 16:03:57 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-08-13 16:03:57 +0100 |
commit | d2212a49f6d447a14cdc87a9de2a4844e78b6905 (patch) | |
tree | b9c7e76342b631709ecc7cea807dd82a43539312 /crates/ra_ide/src/lib.rs | |
parent | e9926948ca267932ccc1341388bfd1b3fa88a001 (diff) | |
parent | ae3abd6e575940eb1221acf26c09e96352f052fa (diff) |
Merge #5748
5748: Rename ra_ssr -> ssr
r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_ide/src/lib.rs')
-rw-r--r-- | crates/ra_ide/src/lib.rs | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/crates/ra_ide/src/lib.rs b/crates/ra_ide/src/lib.rs index 789fbdaf2..bbc9e4b8a 100644 --- a/crates/ra_ide/src/lib.rs +++ b/crates/ra_ide/src/lib.rs | |||
@@ -3,7 +3,7 @@ | |||
3 | //! Strings, suitable for displaying to the human. | 3 | //! Strings, suitable for displaying to the human. |
4 | //! | 4 | //! |
5 | //! What powers this API are the `RootDatabase` struct, which defines a `salsa` | 5 | //! What powers this API are the `RootDatabase` struct, which defines a `salsa` |
6 | //! database, and the `ra_hir` crate, where majority of the analysis happens. | 6 | //! database, and the `hir` crate, where majority of the analysis happens. |
7 | //! However, IDE specific bits of the analysis (most notably completion) happen | 7 | //! However, IDE specific bits of the analysis (most notably completion) happen |
8 | //! in this crate. | 8 | //! in this crate. |
9 | 9 | ||
@@ -39,7 +39,6 @@ mod matching_brace; | |||
39 | mod parent_module; | 39 | mod parent_module; |
40 | mod references; | 40 | mod references; |
41 | mod runnables; | 41 | mod runnables; |
42 | mod ssr; | ||
43 | mod status; | 42 | mod status; |
44 | mod syntax_highlighting; | 43 | mod syntax_highlighting; |
45 | mod syntax_tree; | 44 | mod syntax_tree; |
@@ -52,7 +51,7 @@ use base_db::{ | |||
52 | CheckCanceled, Env, FileLoader, FileSet, SourceDatabase, VfsPath, | 51 | CheckCanceled, Env, FileLoader, FileSet, SourceDatabase, VfsPath, |
53 | }; | 52 | }; |
54 | use cfg::CfgOptions; | 53 | use cfg::CfgOptions; |
55 | use ra_ide_db::{ | 54 | use ide_db::{ |
56 | symbol_index::{self, FileSymbol}, | 55 | symbol_index::{self, FileSymbol}, |
57 | LineIndexDatabase, | 56 | LineIndexDatabase, |
58 | }; | 57 | }; |
@@ -86,8 +85,7 @@ pub use base_db::{ | |||
86 | SourceRootId, | 85 | SourceRootId, |
87 | }; | 86 | }; |
88 | pub use hir::{Documentation, Semantics}; | 87 | pub use hir::{Documentation, Semantics}; |
89 | pub use ra_assists::{Assist, AssistConfig, AssistId, AssistKind, ResolvedAssist}; | 88 | pub use ide_db::{ |
90 | pub use ra_ide_db::{ | ||
91 | change::AnalysisChange, | 89 | change::AnalysisChange, |
92 | line_index::{LineCol, LineIndex}, | 90 | line_index::{LineCol, LineIndex}, |
93 | search::SearchScope, | 91 | search::SearchScope, |
@@ -95,7 +93,8 @@ pub use ra_ide_db::{ | |||
95 | symbol_index::Query, | 93 | symbol_index::Query, |
96 | RootDatabase, | 94 | RootDatabase, |
97 | }; | 95 | }; |
98 | pub use ra_ssr::SsrError; | 96 | pub use ra_assists::{Assist, AssistConfig, AssistId, AssistKind, ResolvedAssist}; |
97 | pub use ssr::SsrError; | ||
99 | pub use text_edit::{Indel, TextEdit}; | 98 | pub use text_edit::{Indel, TextEdit}; |
100 | 99 | ||
101 | pub type Cancelable<T> = Result<T, Canceled>; | 100 | pub type Cancelable<T> = Result<T, Canceled>; |
@@ -515,20 +514,23 @@ impl Analysis { | |||
515 | &self, | 514 | &self, |
516 | query: &str, | 515 | query: &str, |
517 | parse_only: bool, | 516 | parse_only: bool, |
518 | position: FilePosition, | 517 | resolve_context: FilePosition, |
519 | selections: Vec<FileRange>, | 518 | selections: Vec<FileRange>, |
520 | ) -> Cancelable<Result<SourceChange, SsrError>> { | 519 | ) -> Cancelable<Result<SourceChange, SsrError>> { |
521 | self.with_db(|db| { | 520 | 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() }; | ||
523 | Ok(SourceChange::from(edits)) | 525 | Ok(SourceChange::from(edits)) |
524 | }) | 526 | }) |
525 | } | 527 | } |
526 | 528 | ||
527 | /// Performs an operation on that may be Canceled. | 529 | /// Performs an operation on that may be Canceled. |
528 | fn with_db<F: FnOnce(&RootDatabase) -> T + std::panic::UnwindSafe, T>( | 530 | fn with_db<F, T>(&self, f: F) -> Cancelable<T> |
529 | &self, | 531 | where |
530 | f: F, | 532 | F: FnOnce(&RootDatabase) -> T + std::panic::UnwindSafe, |
531 | ) -> Cancelable<T> { | 533 | { |
532 | self.db.catch_canceled(f) | 534 | self.db.catch_canceled(f) |
533 | } | 535 | } |
534 | } | 536 | } |