From a5cc9a8a9ba1e6a0fc281e149881abdd3bd075c1 Mon Sep 17 00:00:00 2001 From: Jeremy Kolb Date: Mon, 25 May 2020 13:35:52 -0400 Subject: Fix some clippy perf warnings --- crates/ra_ide/src/ssr.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'crates/ra_ide/src/ssr.rs') diff --git a/crates/ra_ide/src/ssr.rs b/crates/ra_ide/src/ssr.rs index 1873d1d0d..130d3b4c3 100644 --- a/crates/ra_ide/src/ssr.rs +++ b/crates/ra_ide/src/ssr.rs @@ -196,10 +196,10 @@ fn find(pattern: &SsrPattern, code: &SyntaxNode) -> SsrMatches { ) -> Option { let match_ = check_opt_nodes(pattern.path(), code.path(), placeholders, match_)?; - let mut pattern_fields = - pattern.record_field_list().map(|x| x.fields().collect()).unwrap_or(vec![]); - let mut code_fields = - code.record_field_list().map(|x| x.fields().collect()).unwrap_or(vec![]); + let mut pattern_fields: Vec = + pattern.record_field_list().map(|x| x.fields().collect()).unwrap_or_default(); + let mut code_fields: Vec = + code.record_field_list().map(|x| x.fields().collect()).unwrap_or_default(); if pattern_fields.len() != code_fields.len() { return None; -- cgit v1.2.3 From b795a07320e13bcbedb6435bcfddb3ecd0ed2bde Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 31 May 2020 10:14:36 +0200 Subject: Doc more features --- crates/ra_ide/src/ssr.rs | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'crates/ra_ide/src/ssr.rs') diff --git a/crates/ra_ide/src/ssr.rs b/crates/ra_ide/src/ssr.rs index 130d3b4c3..93e9aee1d 100644 --- a/crates/ra_ide/src/ssr.rs +++ b/crates/ra_ide/src/ssr.rs @@ -1,5 +1,3 @@ -//! structural search replace - use std::{collections::HashMap, iter::once, str::FromStr}; use ra_db::{SourceDatabase, SourceDatabaseExt}; @@ -25,6 +23,28 @@ impl std::fmt::Display for SsrError { impl std::error::Error for SsrError {} +// Feature: Structural Seach and Replace +// +// Search and replace with named wildcards that will match any expression. +// The syntax for a structural search replace command is ` ==>> `. +// A `$:expr` placeholder in the search pattern will match any expression and `$` will reference it in the replacement. +// Available via the command `rust-analyzer.ssr`. +// +// ```rust +// // Using structural search replace command [foo($a:expr, $b:expr) ==>> ($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( query: &str, parse_only: bool, -- cgit v1.2.3