aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-05-31 09:14:36 +0100
committerAleksey Kladov <[email protected]>2020-05-31 09:14:36 +0100
commitb795a07320e13bcbedb6435bcfddb3ecd0ed2bde (patch)
treed8cda2dc671833f42493e12f9eb56b782883f7b7
parent8915183d7da07a4b295e5e93a889dea4c15024a0 (diff)
Doc more features
-rw-r--r--crates/ra_ide/src/expand_macro.rs11
-rw-r--r--crates/ra_ide/src/ssr.rs24
-rw-r--r--crates/ra_ide/src/status.rs11
-rw-r--r--docs/user/features.md48
-rw-r--r--docs/user/readme.adoc7
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 f536ba3e7..54a47aac0 100644
--- a/crates/ra_ide/src/expand_macro.rs
+++ b/crates/ra_ide/src/expand_macro.rs
@@ -1,5 +1,3 @@
1//! This modules implements "expand macro" functionality in the IDE
2
3use hir::Semantics; 1use hir::Semantics;
4use ra_ide_db::RootDatabase; 2use ra_ide_db::RootDatabase;
5use ra_syntax::{ 3use ra_syntax::{
@@ -14,6 +12,15 @@ pub struct ExpandedMacro {
14 pub expansion: String, 12 pub expansion: String,
15} 13}
16 14
15// Feature: Expand Macro Recursively
16//
17// Shows the full macro expansion of the macro at current cursor.
18//
19// |===
20// | Editor | Action Name
21//
22// | VS Code | **Rust Analyzer: Expand macro recursively**
23// |===
17pub(crate) fn expand_macro(db: &RootDatabase, position: FilePosition) -> Option<ExpandedMacro> { 24pub(crate) fn expand_macro(db: &RootDatabase, position: FilePosition) -> Option<ExpandedMacro> {
18 let sema = Semantics::new(db); 25 let sema = Semantics::new(db);
19 let file = sema.parse(position.file_id); 26 let file = sema.parse(position.file_id);
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 @@
1//! structural search replace
2
3use std::{collections::HashMap, iter::once, str::FromStr}; 1use std::{collections::HashMap, iter::once, str::FromStr};
4 2
5use ra_db::{SourceDatabase, SourceDatabaseExt}; 3use ra_db::{SourceDatabase, SourceDatabaseExt};
@@ -25,6 +23,28 @@ impl std::fmt::Display for SsrError {
25 23
26impl std::error::Error for SsrError {} 24impl std::error::Error for SsrError {}
27 25
26// Feature: Structural Seach and Replace
27//
28// Search and replace with named wildcards that will match any expression.
29// The syntax for a structural search replace command is `<search_pattern> ==>> <replace_pattern>`.
30// A `$<name>:expr` placeholder in the search pattern will match any expression and `$<name>` will reference it in the replacement.
31// Available via the command `rust-analyzer.ssr`.
32//
33// ```rust
34// // Using structural search replace command [foo($a:expr, $b:expr) ==>> ($a).foo($b)]
35//
36// // BEFORE
37// String::from(foo(y + 5, z))
38//
39// // AFTER
40// String::from((y + 5).foo(z))
41// ```
42//
43// |===
44// | Editor | Action Name
45//
46// | VS Code | **Rust Analyzer: Structural Search Replace**
47// |===
28pub fn parse_search_replace( 48pub fn parse_search_replace(
29 query: &str, 49 query: &str,
30 parse_only: bool, 50 parse_only: bool,
diff --git a/crates/ra_ide/src/status.rs b/crates/ra_ide/src/status.rs
index 30eb5c995..5b7992920 100644
--- a/crates/ra_ide/src/status.rs
+++ b/crates/ra_ide/src/status.rs
@@ -1,5 +1,3 @@
1//! FIXME: write short doc here
2
3use std::{fmt, iter::FromIterator, sync::Arc}; 1use std::{fmt, iter::FromIterator, sync::Arc};
4 2
5use hir::MacroFile; 3use hir::MacroFile;
@@ -26,6 +24,15 @@ fn macro_syntax_tree_stats(db: &RootDatabase) -> SyntaxTreeStats {
26 db.query(hir::db::ParseMacroQuery).entries::<SyntaxTreeStats>() 24 db.query(hir::db::ParseMacroQuery).entries::<SyntaxTreeStats>()
27} 25}
28 26
27// Feature: Status
28//
29// Shows internal statistic about memory usage of rust-analyzer.
30//
31// |===
32// | Editor | Action Name
33//
34// | VS Code | **Rust Analyzer: Status**
35// |===
29pub(crate) fn status(db: &RootDatabase) -> String { 36pub(crate) fn status(db: &RootDatabase) -> String {
30 let files_stats = db.query(FileTextQuery).entries::<FilesStats>(); 37 let files_stats = db.query(FileTextQuery).entries::<FilesStats>();
31 let syntax_tree_stats = syntax_tree_stats(db); 38 let syntax_tree_stats = syntax_tree_stats(db);
diff --git a/docs/user/features.md b/docs/user/features.md
index ba7ca15a6..ff8cb2d6e 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.
5### Commands <kbd>ctrl+shift+p</kbd> 5### Commands <kbd>ctrl+shift+p</kbd>
6 6
7 7
8
9
10#### Expand Macro Recursively
11
12Shows the full macro expansion of the macro at current cursor.
13
14#### Status
15
16Shows internal statistic about memory usage of rust-analyzer.
17
18#### Show RA Version
19
20Show current rust-analyzer version.
21
22#### Toggle inlay hints 8#### Toggle inlay hints
23 9
24Toggle inlay hints view for the current workspace. 10Toggle inlay hints view for the current workspace.
25It is recommended to assign a shortcut for this command to quickly turn off 11It is recommended to assign a shortcut for this command to quickly turn off
26inlay hints when they prevent you from reading/writing the code. 12inlay hints when they prevent you from reading/writing the code.
27 13
28#### Run Garbage Collection
29
30Manually triggers GC.
31
32#### Start Cargo Watch
33
34Start `cargo watch` for live error highlighting. Will prompt to install if it's not already installed.
35
36#### Stop Cargo Watch
37
38Stop `cargo watch`.
39
40#### Structural Seach and Replace
41
42Search and replace with named wildcards that will match any expression.
43The 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`.
44
45```rust
46// Using structural search replace command [foo($a:expr, $b:expr) ==>> ($a).foo($b)]
47
48// BEFORE
49String::from(foo(y + 5, z))
50
51// AFTER
52String::from((y + 5).foo(z))
53```
54
55### Assists (Code Actions)
56
57Assists, or code actions, are small local refactorings, available in a particular context.
58They are usually triggered by a shortcut or by clicking a light bulb icon in the editor.
59
60See [assists.md](./assists.md) for the list of available assists.
61
62### Magic Completions 14### Magic Completions
63 15
64In addition to usual reference completion, rust-analyzer provides some ✨magic✨ 16In addition to usual reference completion, rust-analyzer provides some ✨magic✨
diff --git a/docs/user/readme.adoc b/docs/user/readme.adoc
index 7b159bfc6..8cfa41144 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
272== Features 272== Features
273 273
274include::./generated_features.adoc[] 274include::./generated_features.adoc[]
275
276== Assists (Code Actions)
277
278Assists, or code actions, are small local refactorings, available in a particular context.
279They are usually triggered by a shortcut or by clicking a light bulb icon in the editor.
280
281See [assists.md](./assists.md) for the list of available assists.