From ae71a631fd657368e8593feb5e025d23147afe60 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 13 Aug 2020 16:36:55 +0200 Subject: Rename ra_hir -> hir --- crates/ra_ide/Cargo.toml | 2 +- crates/ra_ide/src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'crates/ra_ide') diff --git a/crates/ra_ide/Cargo.toml b/crates/ra_ide/Cargo.toml index 1af51f3ae..a701cdf1d 100644 --- a/crates/ra_ide/Cargo.toml +++ b/crates/ra_ide/Cargo.toml @@ -33,7 +33,7 @@ ra_ssr = { path = "../ra_ssr" } # ra_ide should depend only on the top-level `hir` package. if you need # something from some `hir_xxx` subpackage, reexport the API via `hir`. -hir = { path = "../ra_hir", package = "ra_hir" } +hir = { path = "../hir" } [dev-dependencies] expect = { path = "../expect" } diff --git a/crates/ra_ide/src/lib.rs b/crates/ra_ide/src/lib.rs index 789fbdaf2..0d14c823a 100644 --- a/crates/ra_ide/src/lib.rs +++ b/crates/ra_ide/src/lib.rs @@ -3,7 +3,7 @@ //! Strings, suitable for displaying to the human. //! //! What powers this API are the `RootDatabase` struct, which defines a `salsa` -//! database, and the `ra_hir` crate, where majority of the analysis happens. +//! database, and the `hir` crate, where majority of the analysis happens. //! However, IDE specific bits of the analysis (most notably completion) happen //! in this crate. -- cgit v1.2.3 From bb5c189b7dae1ea63ccd5d7a0c2e097d7c676f77 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 13 Aug 2020 16:39:16 +0200 Subject: Rename ra_ide_db -> ide_db --- crates/ra_ide/Cargo.toml | 2 +- crates/ra_ide/src/call_hierarchy.rs | 2 +- crates/ra_ide/src/call_info.rs | 2 +- crates/ra_ide/src/completion.rs | 2 +- crates/ra_ide/src/completion/completion_context.rs | 2 +- crates/ra_ide/src/diagnostics.rs | 2 +- crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs | 2 +- crates/ra_ide/src/display/navigation_target.rs | 2 +- crates/ra_ide/src/expand_macro.rs | 2 +- crates/ra_ide/src/extend_selection.rs | 2 +- crates/ra_ide/src/goto_definition.rs | 2 +- crates/ra_ide/src/goto_implementation.rs | 2 +- crates/ra_ide/src/goto_type_definition.rs | 2 +- crates/ra_ide/src/hover.rs | 4 ++-- crates/ra_ide/src/inlay_hints.rs | 2 +- crates/ra_ide/src/lib.rs | 6 +++--- crates/ra_ide/src/parent_module.rs | 2 +- crates/ra_ide/src/references.rs | 4 ++-- crates/ra_ide/src/references/rename.rs | 2 +- crates/ra_ide/src/runnables.rs | 2 +- crates/ra_ide/src/ssr.rs | 2 +- crates/ra_ide/src/status.rs | 4 ++-- crates/ra_ide/src/syntax_highlighting.rs | 2 +- crates/ra_ide/src/syntax_tree.rs | 2 +- crates/ra_ide/src/typing.rs | 2 +- crates/ra_ide/src/typing/on_enter.rs | 2 +- 26 files changed, 31 insertions(+), 31 deletions(-) (limited to 'crates/ra_ide') diff --git a/crates/ra_ide/Cargo.toml b/crates/ra_ide/Cargo.toml index a701cdf1d..e25aad6cf 100644 --- a/crates/ra_ide/Cargo.toml +++ b/crates/ra_ide/Cargo.toml @@ -24,7 +24,7 @@ stdx = { path = "../stdx" } syntax = { path = "../syntax" } text_edit = { path = "../text_edit" } base_db = { path = "../base_db" } -ra_ide_db = { path = "../ra_ide_db" } +ide_db = { path = "../ide_db" } cfg = { path = "../cfg" } profile = { path = "../profile" } test_utils = { path = "../test_utils" } diff --git a/crates/ra_ide/src/call_hierarchy.rs b/crates/ra_ide/src/call_hierarchy.rs index 3578b8d3c..58e26b94c 100644 --- a/crates/ra_ide/src/call_hierarchy.rs +++ b/crates/ra_ide/src/call_hierarchy.rs @@ -3,7 +3,7 @@ use indexmap::IndexMap; use hir::Semantics; -use ra_ide_db::RootDatabase; +use ide_db::RootDatabase; use syntax::{ast, match_ast, AstNode, TextRange}; use crate::{ diff --git a/crates/ra_ide/src/call_info.rs b/crates/ra_ide/src/call_info.rs index 703cbc6b4..86abd2d8c 100644 --- a/crates/ra_ide/src/call_info.rs +++ b/crates/ra_ide/src/call_info.rs @@ -1,7 +1,7 @@ //! FIXME: write short doc here use either::Either; use hir::{Docs, HirDisplay, Semantics, Type}; -use ra_ide_db::RootDatabase; +use ide_db::RootDatabase; use stdx::format_to; use syntax::{ ast::{self, ArgListOwner}, diff --git a/crates/ra_ide/src/completion.rs b/crates/ra_ide/src/completion.rs index 68ac05e4c..7fb4d687e 100644 --- a/crates/ra_ide/src/completion.rs +++ b/crates/ra_ide/src/completion.rs @@ -19,7 +19,7 @@ mod complete_postfix; mod complete_macro_in_item_position; mod complete_trait_impl; -use ra_ide_db::RootDatabase; +use ide_db::RootDatabase; use crate::{ completion::{ diff --git a/crates/ra_ide/src/completion/completion_context.rs b/crates/ra_ide/src/completion/completion_context.rs index 0e0a201d0..047ecd9d7 100644 --- a/crates/ra_ide/src/completion/completion_context.rs +++ b/crates/ra_ide/src/completion/completion_context.rs @@ -2,7 +2,7 @@ use base_db::SourceDatabase; use hir::{Semantics, SemanticsScope, Type}; -use ra_ide_db::RootDatabase; +use ide_db::RootDatabase; use syntax::{ algo::{find_covering_element, find_node_at_offset}, ast, match_ast, AstNode, NodeOrToken, diff --git a/crates/ra_ide/src/diagnostics.rs b/crates/ra_ide/src/diagnostics.rs index 4e59e3a48..a3ec98178 100644 --- a/crates/ra_ide/src/diagnostics.rs +++ b/crates/ra_ide/src/diagnostics.rs @@ -8,8 +8,8 @@ use std::cell::RefCell; use base_db::SourceDatabase; use hir::{diagnostics::DiagnosticSinkBuilder, Semantics}; +use ide_db::RootDatabase; use itertools::Itertools; -use ra_ide_db::RootDatabase; use syntax::{ ast::{self, AstNode}, SyntaxNode, TextRange, T, diff --git a/crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs b/crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs index 7e126d7a6..85b46c995 100644 --- a/crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs +++ b/crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs @@ -8,7 +8,7 @@ use hir::{ diagnostics::{Diagnostic, MissingFields, MissingOkInTailExpr, NoSuchField, UnresolvedModule}, HasSource, HirDisplay, Semantics, VariantDef, }; -use ra_ide_db::{ +use ide_db::{ source_change::{FileSystemEdit, SourceFileEdit}, RootDatabase, }; diff --git a/crates/ra_ide/src/display/navigation_target.rs b/crates/ra_ide/src/display/navigation_target.rs index 09ec3f65e..e77106177 100644 --- a/crates/ra_ide/src/display/navigation_target.rs +++ b/crates/ra_ide/src/display/navigation_target.rs @@ -3,7 +3,7 @@ use base_db::{FileId, SourceDatabase}; use either::Either; use hir::{original_range, AssocItem, FieldSource, HasSource, InFile, ModuleSource}; -use ra_ide_db::{defs::Definition, RootDatabase}; +use ide_db::{defs::Definition, RootDatabase}; use syntax::{ ast::{self, DocCommentsOwner, NameOwner}, match_ast, AstNode, SmolStr, diff --git a/crates/ra_ide/src/expand_macro.rs b/crates/ra_ide/src/expand_macro.rs index c25e068d6..31455709d 100644 --- a/crates/ra_ide/src/expand_macro.rs +++ b/crates/ra_ide/src/expand_macro.rs @@ -1,5 +1,5 @@ use hir::Semantics; -use ra_ide_db::RootDatabase; +use ide_db::RootDatabase; use syntax::{ algo::{find_node_at_offset, SyntaxRewriter}, ast, AstNode, NodeOrToken, SyntaxKind, diff --git a/crates/ra_ide/src/extend_selection.rs b/crates/ra_ide/src/extend_selection.rs index f30df2bff..34563a026 100644 --- a/crates/ra_ide/src/extend_selection.rs +++ b/crates/ra_ide/src/extend_selection.rs @@ -1,7 +1,7 @@ use std::iter::successors; use hir::Semantics; -use ra_ide_db::RootDatabase; +use ide_db::RootDatabase; use syntax::{ algo::{self, find_covering_element, skip_trivia_token}, ast::{self, AstNode, AstToken}, diff --git a/crates/ra_ide/src/goto_definition.rs b/crates/ra_ide/src/goto_definition.rs index b93d116bf..15e9b7fad 100644 --- a/crates/ra_ide/src/goto_definition.rs +++ b/crates/ra_ide/src/goto_definition.rs @@ -1,5 +1,5 @@ use hir::Semantics; -use ra_ide_db::{ +use ide_db::{ defs::{classify_name, classify_name_ref}, symbol_index, RootDatabase, }; diff --git a/crates/ra_ide/src/goto_implementation.rs b/crates/ra_ide/src/goto_implementation.rs index 6dc2ccfd0..f503f4ec5 100644 --- a/crates/ra_ide/src/goto_implementation.rs +++ b/crates/ra_ide/src/goto_implementation.rs @@ -1,5 +1,5 @@ use hir::{Crate, ImplDef, Semantics}; -use ra_ide_db::RootDatabase; +use ide_db::RootDatabase; use syntax::{algo::find_node_at_offset, ast, AstNode}; use crate::{display::ToNav, FilePosition, NavigationTarget, RangeInfo}; diff --git a/crates/ra_ide/src/goto_type_definition.rs b/crates/ra_ide/src/goto_type_definition.rs index 8017ca58c..4a151b150 100644 --- a/crates/ra_ide/src/goto_type_definition.rs +++ b/crates/ra_ide/src/goto_type_definition.rs @@ -1,4 +1,4 @@ -use ra_ide_db::RootDatabase; +use ide_db::RootDatabase; use syntax::{ast, match_ast, AstNode, SyntaxKind::*, SyntaxToken, TokenAtOffset, T}; use crate::{display::ToNav, FilePosition, NavigationTarget, RangeInfo}; diff --git a/crates/ra_ide/src/hover.rs b/crates/ra_ide/src/hover.rs index a74087f87..331aa4db0 100644 --- a/crates/ra_ide/src/hover.rs +++ b/crates/ra_ide/src/hover.rs @@ -3,11 +3,11 @@ use hir::{ Adt, AsAssocItem, AssocItemContainer, Documentation, FieldSource, HasSource, HirDisplay, Module, ModuleDef, ModuleSource, Semantics, }; -use itertools::Itertools; -use ra_ide_db::{ +use ide_db::{ defs::{classify_name, classify_name_ref, Definition}, RootDatabase, }; +use itertools::Itertools; use stdx::format_to; use syntax::{ast, match_ast, AstNode, SyntaxKind::*, SyntaxToken, TokenAtOffset, T}; use test_utils::mark; diff --git a/crates/ra_ide/src/inlay_hints.rs b/crates/ra_ide/src/inlay_hints.rs index 81fe274ad..002adf915 100644 --- a/crates/ra_ide/src/inlay_hints.rs +++ b/crates/ra_ide/src/inlay_hints.rs @@ -1,5 +1,5 @@ use hir::{Adt, Callable, HirDisplay, Semantics, Type}; -use ra_ide_db::RootDatabase; +use ide_db::RootDatabase; use stdx::to_lower_snake_case; use syntax::{ ast::{self, ArgListOwner, AstNode}, diff --git a/crates/ra_ide/src/lib.rs b/crates/ra_ide/src/lib.rs index 0d14c823a..66a234fff 100644 --- a/crates/ra_ide/src/lib.rs +++ b/crates/ra_ide/src/lib.rs @@ -52,7 +52,7 @@ use base_db::{ CheckCanceled, Env, FileLoader, FileSet, SourceDatabase, VfsPath, }; use cfg::CfgOptions; -use ra_ide_db::{ +use ide_db::{ symbol_index::{self, FileSymbol}, LineIndexDatabase, }; @@ -86,8 +86,7 @@ pub use base_db::{ SourceRootId, }; pub use hir::{Documentation, Semantics}; -pub use ra_assists::{Assist, AssistConfig, AssistId, AssistKind, ResolvedAssist}; -pub use ra_ide_db::{ +pub use ide_db::{ change::AnalysisChange, line_index::{LineCol, LineIndex}, search::SearchScope, @@ -95,6 +94,7 @@ pub use ra_ide_db::{ symbol_index::Query, RootDatabase, }; +pub use ra_assists::{Assist, AssistConfig, AssistId, AssistKind, ResolvedAssist}; pub use ra_ssr::SsrError; pub use text_edit::{Indel, TextEdit}; diff --git a/crates/ra_ide/src/parent_module.rs b/crates/ra_ide/src/parent_module.rs index 8439e1d5d..59ed2967c 100644 --- a/crates/ra_ide/src/parent_module.rs +++ b/crates/ra_ide/src/parent_module.rs @@ -1,6 +1,6 @@ use base_db::{CrateId, FileId, FilePosition}; use hir::Semantics; -use ra_ide_db::RootDatabase; +use ide_db::RootDatabase; use syntax::{ algo::find_node_at_offset, ast::{self, AstNode}, diff --git a/crates/ra_ide/src/references.rs b/crates/ra_ide/src/references.rs index e89dca869..0a76ec6b4 100644 --- a/crates/ra_ide/src/references.rs +++ b/crates/ra_ide/src/references.rs @@ -12,7 +12,7 @@ mod rename; use hir::Semantics; -use ra_ide_db::{ +use ide_db::{ defs::{classify_name, classify_name_ref, Definition}, search::SearchScope, RootDatabase, @@ -27,7 +27,7 @@ use crate::{display::TryToNav, FilePosition, FileRange, NavigationTarget, RangeI pub(crate) use self::rename::rename; -pub use ra_ide_db::search::{Reference, ReferenceAccess, ReferenceKind}; +pub use ide_db::search::{Reference, ReferenceAccess, ReferenceKind}; #[derive(Debug, Clone)] pub struct ReferenceSearchResult { diff --git a/crates/ra_ide/src/references/rename.rs b/crates/ra_ide/src/references/rename.rs index 5697b9d87..d73dc9cd0 100644 --- a/crates/ra_ide/src/references/rename.rs +++ b/crates/ra_ide/src/references/rename.rs @@ -2,7 +2,7 @@ use base_db::SourceDatabaseExt; use hir::{Module, ModuleDef, ModuleSource, Semantics}; -use ra_ide_db::{ +use ide_db::{ defs::{classify_name, classify_name_ref, Definition, NameClass, NameRefClass}, RootDatabase, }; diff --git a/crates/ra_ide/src/runnables.rs b/crates/ra_ide/src/runnables.rs index fb40762cf..c3e07c8de 100644 --- a/crates/ra_ide/src/runnables.rs +++ b/crates/ra_ide/src/runnables.rs @@ -2,8 +2,8 @@ use std::fmt; use cfg::CfgExpr; use hir::{AsAssocItem, Attrs, HirFileId, InFile, Semantics}; +use ide_db::RootDatabase; use itertools::Itertools; -use ra_ide_db::RootDatabase; use syntax::{ ast::{self, AstNode, AttrsOwner, DocCommentsOwner, ModuleItemOwner, NameOwner}, match_ast, SyntaxNode, diff --git a/crates/ra_ide/src/ssr.rs b/crates/ra_ide/src/ssr.rs index 97b82b70e..a8a704192 100644 --- a/crates/ra_ide/src/ssr.rs +++ b/crates/ra_ide/src/ssr.rs @@ -1,5 +1,5 @@ use base_db::{FilePosition, FileRange}; -use ra_ide_db::RootDatabase; +use ide_db::RootDatabase; use crate::SourceFileEdit; use ra_ssr::{MatchFinder, SsrError, SsrRule}; diff --git a/crates/ra_ide/src/status.rs b/crates/ra_ide/src/status.rs index 869c74acc..c23708181 100644 --- a/crates/ra_ide/src/status.rs +++ b/crates/ra_ide/src/status.rs @@ -5,11 +5,11 @@ use base_db::{ FileTextQuery, SourceRootId, }; use hir::MacroFile; -use profile::{memory_usage, Bytes}; -use ra_ide_db::{ +use ide_db::{ symbol_index::{LibrarySymbolsQuery, SymbolIndex}, RootDatabase, }; +use profile::{memory_usage, Bytes}; use rustc_hash::FxHashMap; use syntax::{ast, Parse, SyntaxNode}; diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs index 4b41ceb1d..5d7c7e8d0 100644 --- a/crates/ra_ide/src/syntax_highlighting.rs +++ b/crates/ra_ide/src/syntax_highlighting.rs @@ -5,7 +5,7 @@ mod injection; mod tests; use hir::{Name, Semantics, VariantDef}; -use ra_ide_db::{ +use ide_db::{ defs::{classify_name, classify_name_ref, Definition, NameClass, NameRefClass}, RootDatabase, }; diff --git a/crates/ra_ide/src/syntax_tree.rs b/crates/ra_ide/src/syntax_tree.rs index 17daf06b6..f80044959 100644 --- a/crates/ra_ide/src/syntax_tree.rs +++ b/crates/ra_ide/src/syntax_tree.rs @@ -1,5 +1,5 @@ use base_db::{FileId, SourceDatabase}; -use ra_ide_db::RootDatabase; +use ide_db::RootDatabase; use syntax::{ algo, AstNode, NodeOrToken, SourceFile, SyntaxKind::{RAW_STRING, STRING}, diff --git a/crates/ra_ide/src/typing.rs b/crates/ra_ide/src/typing.rs index 75f2a6b60..899ce5f26 100644 --- a/crates/ra_ide/src/typing.rs +++ b/crates/ra_ide/src/typing.rs @@ -16,7 +16,7 @@ mod on_enter; use base_db::{FilePosition, SourceDatabase}; -use ra_ide_db::{source_change::SourceFileEdit, RootDatabase}; +use ide_db::{source_change::SourceFileEdit, RootDatabase}; use syntax::{ algo::find_node_at_offset, ast::{self, edit::IndentLevel, AstToken}, diff --git a/crates/ra_ide/src/typing/on_enter.rs b/crates/ra_ide/src/typing/on_enter.rs index 193930659..f7d46146c 100644 --- a/crates/ra_ide/src/typing/on_enter.rs +++ b/crates/ra_ide/src/typing/on_enter.rs @@ -2,7 +2,7 @@ //! comments, but should handle indent some time in the future as well. use base_db::{FilePosition, SourceDatabase}; -use ra_ide_db::RootDatabase; +use ide_db::RootDatabase; use syntax::{ ast::{self, AstToken}, AstNode, SmolStr, SourceFile, -- cgit v1.2.3 From ae3abd6e575940eb1221acf26c09e96352f052fa Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 13 Aug 2020 16:45:10 +0200 Subject: Rename ra_ssr -> ssr --- crates/ra_ide/Cargo.toml | 2 +- crates/ra_ide/src/lib.rs | 18 ++++++------ crates/ra_ide/src/ssr.rs | 72 ------------------------------------------------ 3 files changed, 11 insertions(+), 81 deletions(-) delete mode 100644 crates/ra_ide/src/ssr.rs (limited to 'crates/ra_ide') diff --git a/crates/ra_ide/Cargo.toml b/crates/ra_ide/Cargo.toml index e25aad6cf..8519e9cca 100644 --- a/crates/ra_ide/Cargo.toml +++ b/crates/ra_ide/Cargo.toml @@ -29,7 +29,7 @@ cfg = { path = "../cfg" } profile = { path = "../profile" } test_utils = { path = "../test_utils" } ra_assists = { path = "../ra_assists" } -ra_ssr = { path = "../ra_ssr" } +ssr = { path = "../ssr" } # ra_ide should depend only on the top-level `hir` package. if you need # something from some `hir_xxx` subpackage, reexport the API via `hir`. diff --git a/crates/ra_ide/src/lib.rs b/crates/ra_ide/src/lib.rs index 66a234fff..bbc9e4b8a 100644 --- a/crates/ra_ide/src/lib.rs +++ b/crates/ra_ide/src/lib.rs @@ -39,7 +39,6 @@ mod matching_brace; mod parent_module; mod references; mod runnables; -mod ssr; mod status; mod syntax_highlighting; mod syntax_tree; @@ -95,7 +94,7 @@ pub use ide_db::{ RootDatabase, }; pub use ra_assists::{Assist, AssistConfig, AssistId, AssistKind, ResolvedAssist}; -pub use ra_ssr::SsrError; +pub use ssr::SsrError; pub use text_edit::{Indel, TextEdit}; pub type Cancelable = Result; @@ -515,20 +514,23 @@ impl Analysis { &self, query: &str, parse_only: bool, - position: FilePosition, + resolve_context: FilePosition, selections: Vec, ) -> Cancelable> { self.with_db(|db| { - let edits = ssr::parse_search_replace(query, parse_only, db, position, selections)?; + let rule: ssr::SsrRule = query.parse()?; + let mut match_finder = ssr::MatchFinder::in_context(db, resolve_context, selections); + match_finder.add_rule(rule)?; + let edits = if parse_only { Vec::new() } else { match_finder.edits() }; Ok(SourceChange::from(edits)) }) } /// Performs an operation on that may be Canceled. - fn with_db T + std::panic::UnwindSafe, T>( - &self, - f: F, - ) -> Cancelable { + fn with_db(&self, f: F) -> Cancelable + where + F: FnOnce(&RootDatabase) -> T + std::panic::UnwindSafe, + { self.db.catch_canceled(f) } } diff --git a/crates/ra_ide/src/ssr.rs b/crates/ra_ide/src/ssr.rs deleted file mode 100644 index a8a704192..000000000 --- a/crates/ra_ide/src/ssr.rs +++ /dev/null @@ -1,72 +0,0 @@ -use base_db::{FilePosition, FileRange}; -use ide_db::RootDatabase; - -use crate::SourceFileEdit; -use ra_ssr::{MatchFinder, SsrError, SsrRule}; - -// Feature: Structural Search and Replace -// -// Search and replace with named wildcards that will match any expression, type, path, pattern or item. -// The syntax for a structural search replace command is ` ==>> `. -// A `$` placeholder in the search pattern will match any AST node and `$` will reference it in the replacement. -// Within a macro call, a placeholder will match up until whatever token follows the placeholder. -// -// All paths in both the search pattern and the replacement template must resolve in the context -// in which this command is invoked. Paths in the search pattern will then match the code if they -// resolve to the same item, even if they're written differently. For example if we invoke the -// command in the module `foo` with a pattern of `Bar`, then code in the parent module that refers -// to `foo::Bar` will match. -// -// Paths in the replacement template will be rendered appropriately for the context in which the -// replacement occurs. For example if our replacement template is `foo::Bar` and we match some -// code in the `foo` module, we'll insert just `Bar`. -// -// Inherent method calls should generally be written in UFCS form. e.g. `foo::Bar::baz($s, $a)` will -// match `$s.baz($a)`, provided the method call `baz` resolves to the method `foo::Bar::baz`. -// -// The scope of the search / replace will be restricted to the current selection if any, otherwise -// it will apply to the whole workspace. -// -// Placeholders may be given constraints by writing them as `${::...}`. -// -// Supported constraints: -// -// |=== -// | Constraint | Restricts placeholder -// -// | kind(literal) | Is a literal (e.g. `42` or `"forty two"`) -// | not(a) | Negates the constraint `a` -// |=== -// -// Available via the command `rust-analyzer.ssr`. -// -// ```rust -// // Using structural search replace command [foo($a, $b) ==>> ($a).foo($b)] -// -// // BEFORE -// String::from(foo(y + 5, z)) -// -// // AFTER -// String::from((y + 5).foo(z)) -// ``` -// -// |=== -// | Editor | Action Name -// -// | VS Code | **Rust Analyzer: Structural Search Replace** -// |=== -pub fn parse_search_replace( - rule: &str, - parse_only: bool, - db: &RootDatabase, - resolve_context: FilePosition, - selections: Vec, -) -> Result, SsrError> { - let rule: SsrRule = rule.parse()?; - let mut match_finder = MatchFinder::in_context(db, resolve_context, selections); - match_finder.add_rule(rule)?; - if parse_only { - return Ok(Vec::new()); - } - Ok(match_finder.edits()) -} -- cgit v1.2.3