Skip to content

Commit b795a07

Browse files
committed
Doc more features
1 parent 8915183 commit b795a07

File tree

5 files changed

+47
-54
lines changed

5 files changed

+47
-54
lines changed

crates/ra_ide/src/expand_macro.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
//! This modules implements "expand macro" functionality in the IDE
2-
31
use hir::Semantics;
42
use ra_ide_db::RootDatabase;
53
use ra_syntax::{
@@ -14,6 +12,15 @@ pub struct ExpandedMacro {
1412
pub expansion: String,
1513
}
1614

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+
// |===
1724
pub(crate) fn expand_macro(db: &RootDatabase, position: FilePosition) -> Option<ExpandedMacro> {
1825
let sema = Semantics::new(db);
1926
let file = sema.parse(position.file_id);

crates/ra_ide/src/ssr.rs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
//! structural search replace
2-
31
use std::{collections::HashMap, iter::once, str::FromStr};
42

53
use ra_db::{SourceDatabase, SourceDatabaseExt};
@@ -25,6 +23,28 @@ impl std::fmt::Display for SsrError {
2523

2624
impl std::error::Error for SsrError {}
2725

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+
// |===
2848
pub fn parse_search_replace(
2949
query: &str,
3050
parse_only: bool,

crates/ra_ide/src/status.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
//! FIXME: write short doc here
2-
31
use std::{fmt, iter::FromIterator, sync::Arc};
42

53
use hir::MacroFile;
@@ -26,6 +24,15 @@ fn macro_syntax_tree_stats(db: &RootDatabase) -> SyntaxTreeStats {
2624
db.query(hir::db::ParseMacroQuery).entries::<SyntaxTreeStats>()
2725
}
2826

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+
// |===
2936
pub(crate) fn status(db: &RootDatabase) -> String {
3037
let files_stats = db.query(FileTextQuery).entries::<FilesStats>();
3138
let syntax_tree_stats = syntax_tree_stats(db);

docs/user/features.md

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -5,60 +5,12 @@ you can use <kbd>Ctrl+Shift+P</kbd> to search for the corresponding action.
55
### Commands <kbd>ctrl+shift+p</kbd>
66

77

8-
9-
10-
#### Expand Macro Recursively
11-
12-
Shows the full macro expansion of the macro at current cursor.
13-
14-
#### Status
15-
16-
Shows internal statistic about memory usage of rust-analyzer.
17-
18-
#### Show RA Version
19-
20-
Show current rust-analyzer version.
21-
228
#### Toggle inlay hints
239

2410
Toggle inlay hints view for the current workspace.
2511
It is recommended to assign a shortcut for this command to quickly turn off
2612
inlay hints when they prevent you from reading/writing the code.
2713

28-
#### Run Garbage Collection
29-
30-
Manually triggers GC.
31-
32-
#### Start Cargo Watch
33-
34-
Start `cargo watch` for live error highlighting. Will prompt to install if it's not already installed.
35-
36-
#### Stop Cargo Watch
37-
38-
Stop `cargo watch`.
39-
40-
#### Structural Seach and Replace
41-
42-
Search and replace with named wildcards that will match any expression.
43-
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`.
44-
45-
```rust
46-
// Using structural search replace command [foo($a:expr, $b:expr) ==>> ($a).foo($b)]
47-
48-
// BEFORE
49-
String::from(foo(y + 5, z))
50-
51-
// AFTER
52-
String::from((y + 5).foo(z))
53-
```
54-
55-
### Assists (Code Actions)
56-
57-
Assists, or code actions, are small local refactorings, available in a particular context.
58-
They are usually triggered by a shortcut or by clicking a light bulb icon in the editor.
59-
60-
See [assists.md](./assists.md) for the list of available assists.
61-
6214
### Magic Completions
6315

6416
In addition to usual reference completion, rust-analyzer provides some ✨magic✨

docs/user/readme.adoc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,3 +272,10 @@ Gnome Builder currently has support for RLS, and there's no way to configure the
272272
== Features
273273

274274
include::./generated_features.adoc[]
275+
276+
== Assists (Code Actions)
277+
278+
Assists, or code actions, are small local refactorings, available in a particular context.
279+
They are usually triggered by a shortcut or by clicking a light bulb icon in the editor.
280+
281+
See [assists.md](./assists.md) for the list of available assists.

0 commit comments

Comments
 (0)