diff options
| author | Aleksey Kladov <aleksey.kladov@gmail.com> | 2020-05-31 10:14:36 +0200 |
|---|---|---|
| committer | Aleksey Kladov <aleksey.kladov@gmail.com> | 2020-05-31 10:14:36 +0200 |
| commit | b795a07320e13bcbedb6435bcfddb3ecd0ed2bde (patch) | |
| tree | d8cda2dc671833f42493e12f9eb56b782883f7b7 | |
| parent | 8915183d7da07a4b295e5e93a889dea4c15024a0 (diff) | |
| download | rust-b795a07320e13bcbedb6435bcfddb3ecd0ed2bde.tar.gz rust-b795a07320e13bcbedb6435bcfddb3ecd0ed2bde.zip | |
Doc more features
| -rw-r--r-- | crates/ra_ide/src/expand_macro.rs | 11 | ||||
| -rw-r--r-- | crates/ra_ide/src/ssr.rs | 24 | ||||
| -rw-r--r-- | crates/ra_ide/src/status.rs | 11 | ||||
| -rw-r--r-- | docs/user/features.md | 48 | ||||
| -rw-r--r-- | docs/user/readme.adoc | 7 |
5 files changed, 47 insertions, 54 deletions
diff --git a/crates/ra_ide/src/expand_macro.rs b/crates/ra_ide/src/expand_macro.rs index f536ba3e786..54a47aac068 100644 --- a/crates/ra_ide/src/expand_macro.rs +++ b/crates/ra_ide/src/expand_macro.rs @@ -1,5 +1,3 @@ -//! This modules implements "expand macro" functionality in the IDE - use hir::Semantics; use ra_ide_db::RootDatabase; use ra_syntax::{ @@ -14,6 +12,15 @@ pub struct ExpandedMacro { pub expansion: String, } +// Feature: Expand Macro Recursively +// +// Shows the full macro expansion of the macro at current cursor. +// +// |=== +// | Editor | Action Name +// +// | VS Code | **Rust Analyzer: Expand macro recursively** +// |=== pub(crate) fn expand_macro(db: &RootDatabase, position: FilePosition) -> Option<ExpandedMacro> { let sema = Semantics::new(db); let file = sema.parse(position.file_id); diff --git a/crates/ra_ide/src/ssr.rs b/crates/ra_ide/src/ssr.rs index 130d3b4c3ba..93e9aee1d01 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 `<search_pattern> ==>> <replace_pattern>`. +// A `$<name>:expr` placeholder in the search pattern will match any expression and `$<name>` 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, diff --git a/crates/ra_ide/src/status.rs b/crates/ra_ide/src/status.rs index 30eb5c995e6..5b799292007 100644 --- a/crates/ra_ide/src/status.rs +++ b/crates/ra_ide/src/status.rs @@ -1,5 +1,3 @@ -//! FIXME: write short doc here - use std::{fmt, iter::FromIterator, sync::Arc}; use hir::MacroFile; @@ -26,6 +24,15 @@ fn macro_syntax_tree_stats(db: &RootDatabase) -> SyntaxTreeStats { db.query(hir::db::ParseMacroQuery).entries::<SyntaxTreeStats>() } +// Feature: Status +// +// Shows internal statistic about memory usage of rust-analyzer. +// +// |=== +// | Editor | Action Name +// +// | VS Code | **Rust Analyzer: Status** +// |=== pub(crate) fn status(db: &RootDatabase) -> String { let files_stats = db.query(FileTextQuery).entries::<FilesStats>(); let syntax_tree_stats = syntax_tree_stats(db); diff --git a/docs/user/features.md b/docs/user/features.md index ba7ca15a6b4..ff8cb2d6ef6 100644 --- a/docs/user/features.md +++ b/docs/user/features.md @@ -5,60 +5,12 @@ you can use <kbd>Ctrl+Shift+P</kbd> to search for the corresponding action. ### Commands <kbd>ctrl+shift+p</kbd> - - -#### Expand Macro Recursively - -Shows the full macro expansion of the macro at current cursor. - -#### Status - -Shows internal statistic about memory usage of rust-analyzer. - -#### Show RA Version - -Show current rust-analyzer version. - #### Toggle inlay hints Toggle inlay hints view for the current workspace. It is recommended to assign a shortcut for this command to quickly turn off inlay hints when they prevent you from reading/writing the code. -#### Run Garbage Collection - -Manually triggers GC. - -#### Start Cargo Watch - -Start `cargo watch` for live error highlighting. Will prompt to install if it's not already installed. - -#### Stop Cargo Watch - -Stop `cargo watch`. - -#### Structural Seach and Replace - -Search and replace with named wildcards that will match any expression. -The syntax for a structural search replace command is `<search_pattern> ==>> <replace_pattern>`. A `$<name>:expr` placeholder in the search pattern will match any expression and `$<name>` 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)) -``` - -### Assists (Code Actions) - -Assists, or code actions, are small local refactorings, available in a particular context. -They are usually triggered by a shortcut or by clicking a light bulb icon in the editor. - -See [assists.md](./assists.md) for the list of available assists. - ### Magic Completions In addition to usual reference completion, rust-analyzer provides some ✨magic✨ diff --git a/docs/user/readme.adoc b/docs/user/readme.adoc index 7b159bfc6b7..8cfa41144e7 100644 --- a/docs/user/readme.adoc +++ b/docs/user/readme.adoc @@ -272,3 +272,10 @@ Gnome Builder currently has support for RLS, and there's no way to configure the == Features include::./generated_features.adoc[] + +== Assists (Code Actions) + +Assists, or code actions, are small local refactorings, available in a particular context. +They are usually triggered by a shortcut or by clicking a light bulb icon in the editor. + +See [assists.md](./assists.md) for the list of available assists. |
