diff options
-rw-r--r-- | docs/user/generated_assists.adoc | 42 | ||||
-rw-r--r-- | docs/user/generated_features.adoc | 38 | ||||
-rw-r--r-- | xtask/src/codegen.rs | 39 | ||||
-rw-r--r-- | xtask/src/codegen/gen_assists_docs.rs | 4 | ||||
-rw-r--r-- | xtask/src/codegen/gen_feature_docs.rs | 3 |
5 files changed, 90 insertions, 36 deletions
diff --git a/docs/user/generated_assists.adoc b/docs/user/generated_assists.adoc index b8cdfb1cd..580ab4358 100644 --- a/docs/user/generated_assists.adoc +++ b/docs/user/generated_assists.adoc | |||
@@ -1,5 +1,6 @@ | |||
1 | [discrete] | 1 | [discrete] |
2 | === `add_custom_impl` | 2 | === `add_custom_impl` |
3 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/add_custom_impl.rs#L14[add_custom_impl.rs] | ||
3 | 4 | ||
4 | Adds impl block for derived trait. | 5 | Adds impl block for derived trait. |
5 | 6 | ||
@@ -22,6 +23,7 @@ impl Debug for S { | |||
22 | 23 | ||
23 | [discrete] | 24 | [discrete] |
24 | === `add_derive` | 25 | === `add_derive` |
26 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/add_derive.rs#L9[add_derive.rs] | ||
25 | 27 | ||
26 | Adds a new `#[derive()]` clause to a struct or enum. | 28 | Adds a new `#[derive()]` clause to a struct or enum. |
27 | 29 | ||
@@ -45,6 +47,7 @@ struct Point { | |||
45 | 47 | ||
46 | [discrete] | 48 | [discrete] |
47 | === `add_explicit_type` | 49 | === `add_explicit_type` |
50 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/add_explicit_type.rs#L9[add_explicit_type.rs] | ||
48 | 51 | ||
49 | Specify type for a let binding. | 52 | Specify type for a let binding. |
50 | 53 | ||
@@ -65,6 +68,7 @@ fn main() { | |||
65 | 68 | ||
66 | [discrete] | 69 | [discrete] |
67 | === `add_from_impl_for_enum` | 70 | === `add_from_impl_for_enum` |
71 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/add_from_impl_for_enum.rs#L7[add_from_impl_for_enum.rs] | ||
68 | 72 | ||
69 | Adds a From impl for an enum variant with one tuple field. | 73 | Adds a From impl for an enum variant with one tuple field. |
70 | 74 | ||
@@ -87,6 +91,7 @@ impl From<u32> for A { | |||
87 | 91 | ||
88 | [discrete] | 92 | [discrete] |
89 | === `add_function` | 93 | === `add_function` |
94 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/add_function.rs#L19[add_function.rs] | ||
90 | 95 | ||
91 | Adds a stub function with a signature matching the function under the cursor. | 96 | Adds a stub function with a signature matching the function under the cursor. |
92 | 97 | ||
@@ -117,6 +122,7 @@ fn bar(arg: &str, baz: Baz) { | |||
117 | 122 | ||
118 | [discrete] | 123 | [discrete] |
119 | === `add_hash` | 124 | === `add_hash` |
125 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/raw_string.rs#L65[raw_string.rs] | ||
120 | 126 | ||
121 | Adds a hash to a raw string literal. | 127 | Adds a hash to a raw string literal. |
122 | 128 | ||
@@ -137,6 +143,7 @@ fn main() { | |||
137 | 143 | ||
138 | [discrete] | 144 | [discrete] |
139 | === `add_impl` | 145 | === `add_impl` |
146 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/add_impl.rs#L6[add_impl.rs] | ||
140 | 147 | ||
141 | Adds a new inherent impl for a type. | 148 | Adds a new inherent impl for a type. |
142 | 149 | ||
@@ -161,6 +168,7 @@ impl<T: Clone> Ctx<T> { | |||
161 | 168 | ||
162 | [discrete] | 169 | [discrete] |
163 | === `add_impl_default_members` | 170 | === `add_impl_default_members` |
171 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/add_missing_impl_members.rs#L64[add_missing_impl_members.rs] | ||
164 | 172 | ||
165 | Adds scaffold for overriding default impl members. | 173 | Adds scaffold for overriding default impl members. |
166 | 174 | ||
@@ -198,6 +206,7 @@ impl Trait for () { | |||
198 | 206 | ||
199 | [discrete] | 207 | [discrete] |
200 | === `add_impl_missing_members` | 208 | === `add_impl_missing_members` |
209 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/add_missing_impl_members.rs#L24[add_missing_impl_members.rs] | ||
201 | 210 | ||
202 | Adds scaffold for required impl members. | 211 | Adds scaffold for required impl members. |
203 | 212 | ||
@@ -233,6 +242,7 @@ impl Trait<u32> for () { | |||
233 | 242 | ||
234 | [discrete] | 243 | [discrete] |
235 | === `add_new` | 244 | === `add_new` |
245 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/add_new.rs#L12[add_new.rs] | ||
236 | 246 | ||
237 | Adds a new inherent impl for a type. | 247 | Adds a new inherent impl for a type. |
238 | 248 | ||
@@ -258,6 +268,7 @@ impl<T: Clone> Ctx<T> { | |||
258 | 268 | ||
259 | [discrete] | 269 | [discrete] |
260 | === `add_turbo_fish` | 270 | === `add_turbo_fish` |
271 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/add_turbo_fish.rs#L10[add_turbo_fish.rs] | ||
261 | 272 | ||
262 | Adds `::<_>` to a call of a generic method or function. | 273 | Adds `::<_>` to a call of a generic method or function. |
263 | 274 | ||
@@ -280,6 +291,7 @@ fn main() { | |||
280 | 291 | ||
281 | [discrete] | 292 | [discrete] |
282 | === `apply_demorgan` | 293 | === `apply_demorgan` |
294 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/apply_demorgan.rs#L5[apply_demorgan.rs] | ||
283 | 295 | ||
284 | Apply [De Morgan's law](https://en.wikipedia.org/wiki/De_Morgan%27s_laws). | 296 | Apply [De Morgan's law](https://en.wikipedia.org/wiki/De_Morgan%27s_laws). |
285 | This transforms expressions of the form `!l || !r` into `!(l && r)`. | 297 | This transforms expressions of the form `!l || !r` into `!(l && r)`. |
@@ -304,6 +316,7 @@ fn main() { | |||
304 | 316 | ||
305 | [discrete] | 317 | [discrete] |
306 | === `auto_import` | 318 | === `auto_import` |
319 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/auto_import.rs#L18[auto_import.rs] | ||
307 | 320 | ||
308 | If the name is unresolved, provides all possible imports for it. | 321 | If the name is unresolved, provides all possible imports for it. |
309 | 322 | ||
@@ -326,6 +339,7 @@ fn main() { | |||
326 | 339 | ||
327 | [discrete] | 340 | [discrete] |
328 | === `change_lifetime_anon_to_named` | 341 | === `change_lifetime_anon_to_named` |
342 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/change_lifetime_anon_to_named.rs#L9[change_lifetime_anon_to_named.rs] | ||
329 | 343 | ||
330 | Change an anonymous lifetime to a named lifetime. | 344 | Change an anonymous lifetime to a named lifetime. |
331 | 345 | ||
@@ -354,6 +368,7 @@ impl<'a> Cursor<'a> { | |||
354 | 368 | ||
355 | [discrete] | 369 | [discrete] |
356 | === `change_return_type_to_result` | 370 | === `change_return_type_to_result` |
371 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/change_return_type_to_result.rs#L8[change_return_type_to_result.rs] | ||
357 | 372 | ||
358 | Change the function's return type to Result. | 373 | Change the function's return type to Result. |
359 | 374 | ||
@@ -370,6 +385,7 @@ fn foo() -> Result<i32, ${0:_}> { Ok(42i32) } | |||
370 | 385 | ||
371 | [discrete] | 386 | [discrete] |
372 | === `change_visibility` | 387 | === `change_visibility` |
388 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/change_visibility.rs#L14[change_visibility.rs] | ||
373 | 389 | ||
374 | Adds or changes existing visibility specifier. | 390 | Adds or changes existing visibility specifier. |
375 | 391 | ||
@@ -386,6 +402,7 @@ pub(crate) fn frobnicate() {} | |||
386 | 402 | ||
387 | [discrete] | 403 | [discrete] |
388 | === `convert_to_guarded_return` | 404 | === `convert_to_guarded_return` |
405 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/early_return.rs#L21[early_return.rs] | ||
389 | 406 | ||
390 | Replace a large conditional with a guarded return. | 407 | Replace a large conditional with a guarded return. |
391 | 408 | ||
@@ -413,6 +430,7 @@ fn main() { | |||
413 | 430 | ||
414 | [discrete] | 431 | [discrete] |
415 | === `fill_match_arms` | 432 | === `fill_match_arms` |
433 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/fill_match_arms.rs#L14[fill_match_arms.rs] | ||
416 | 434 | ||
417 | Adds missing clauses to a `match` expression. | 435 | Adds missing clauses to a `match` expression. |
418 | 436 | ||
@@ -442,6 +460,7 @@ fn handle(action: Action) { | |||
442 | 460 | ||
443 | [discrete] | 461 | [discrete] |
444 | === `fix_visibility` | 462 | === `fix_visibility` |
463 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/fix_visibility.rs#L13[fix_visibility.rs] | ||
445 | 464 | ||
446 | Makes inaccessible item public. | 465 | Makes inaccessible item public. |
447 | 466 | ||
@@ -468,6 +487,7 @@ fn main() { | |||
468 | 487 | ||
469 | [discrete] | 488 | [discrete] |
470 | === `flip_binexpr` | 489 | === `flip_binexpr` |
490 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/flip_binexpr.rs#L5[flip_binexpr.rs] | ||
471 | 491 | ||
472 | Flips operands of a binary expression. | 492 | Flips operands of a binary expression. |
473 | 493 | ||
@@ -488,6 +508,7 @@ fn main() { | |||
488 | 508 | ||
489 | [discrete] | 509 | [discrete] |
490 | === `flip_comma` | 510 | === `flip_comma` |
511 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/flip_comma.rs#L5[flip_comma.rs] | ||
491 | 512 | ||
492 | Flips two comma-separated items. | 513 | Flips two comma-separated items. |
493 | 514 | ||
@@ -508,6 +529,7 @@ fn main() { | |||
508 | 529 | ||
509 | [discrete] | 530 | [discrete] |
510 | === `flip_trait_bound` | 531 | === `flip_trait_bound` |
532 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/flip_trait_bound.rs#L9[flip_trait_bound.rs] | ||
511 | 533 | ||
512 | Flips two trait bounds. | 534 | Flips two trait bounds. |
513 | 535 | ||
@@ -524,6 +546,7 @@ fn foo<T: Copy + Clone>() { } | |||
524 | 546 | ||
525 | [discrete] | 547 | [discrete] |
526 | === `inline_local_variable` | 548 | === `inline_local_variable` |
549 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/inline_local_variable.rs#L13[inline_local_variable.rs] | ||
527 | 550 | ||
528 | Inlines local variable. | 551 | Inlines local variable. |
529 | 552 | ||
@@ -545,6 +568,7 @@ fn main() { | |||
545 | 568 | ||
546 | [discrete] | 569 | [discrete] |
547 | === `introduce_variable` | 570 | === `introduce_variable` |
571 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/introduce_variable.rs#L14[introduce_variable.rs] | ||
548 | 572 | ||
549 | Extracts subexpression into a variable. | 573 | Extracts subexpression into a variable. |
550 | 574 | ||
@@ -566,6 +590,7 @@ fn main() { | |||
566 | 590 | ||
567 | [discrete] | 591 | [discrete] |
568 | === `invert_if` | 592 | === `invert_if` |
593 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/invert_if.rs#L12[invert_if.rs] | ||
569 | 594 | ||
570 | Apply invert_if | 595 | Apply invert_if |
571 | This transforms if expressions of the form `if !x {A} else {B}` into `if x {B} else {A}` | 596 | This transforms if expressions of the form `if !x {A} else {B}` into `if x {B} else {A}` |
@@ -589,6 +614,7 @@ fn main() { | |||
589 | 614 | ||
590 | [discrete] | 615 | [discrete] |
591 | === `make_raw_string` | 616 | === `make_raw_string` |
617 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/raw_string.rs#L10[raw_string.rs] | ||
592 | 618 | ||
593 | Adds `r#` to a plain string literal. | 619 | Adds `r#` to a plain string literal. |
594 | 620 | ||
@@ -609,6 +635,7 @@ fn main() { | |||
609 | 635 | ||
610 | [discrete] | 636 | [discrete] |
611 | === `make_usual_string` | 637 | === `make_usual_string` |
638 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/raw_string.rs#L39[raw_string.rs] | ||
612 | 639 | ||
613 | Turns a raw string into a plain string. | 640 | Turns a raw string into a plain string. |
614 | 641 | ||
@@ -629,6 +656,7 @@ fn main() { | |||
629 | 656 | ||
630 | [discrete] | 657 | [discrete] |
631 | === `merge_imports` | 658 | === `merge_imports` |
659 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/merge_imports.rs#L14[merge_imports.rs] | ||
632 | 660 | ||
633 | Merges two imports with a common prefix. | 661 | Merges two imports with a common prefix. |
634 | 662 | ||
@@ -646,6 +674,7 @@ use std::{fmt::Formatter, io}; | |||
646 | 674 | ||
647 | [discrete] | 675 | [discrete] |
648 | === `merge_match_arms` | 676 | === `merge_match_arms` |
677 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/merge_match_arms.rs#L11[merge_match_arms.rs] | ||
649 | 678 | ||
650 | Merges identical match arms. | 679 | Merges identical match arms. |
651 | 680 | ||
@@ -675,6 +704,7 @@ fn handle(action: Action) { | |||
675 | 704 | ||
676 | [discrete] | 705 | [discrete] |
677 | === `move_arm_cond_to_match_guard` | 706 | === `move_arm_cond_to_match_guard` |
707 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/move_guard.rs#L56[move_guard.rs] | ||
678 | 708 | ||
679 | Moves if expression from match arm body into a guard. | 709 | Moves if expression from match arm body into a guard. |
680 | 710 | ||
@@ -705,6 +735,7 @@ fn handle(action: Action) { | |||
705 | 735 | ||
706 | [discrete] | 736 | [discrete] |
707 | === `move_bounds_to_where_clause` | 737 | === `move_bounds_to_where_clause` |
738 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/move_bounds.rs#L10[move_bounds.rs] | ||
708 | 739 | ||
709 | Moves inline type bounds to a where clause. | 740 | Moves inline type bounds to a where clause. |
710 | 741 | ||
@@ -725,6 +756,7 @@ fn apply<T, U, F>(f: F, x: T) -> U where F: FnOnce(T) -> U { | |||
725 | 756 | ||
726 | [discrete] | 757 | [discrete] |
727 | === `move_guard_to_arm_body` | 758 | === `move_guard_to_arm_body` |
759 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/move_guard.rs#L8[move_guard.rs] | ||
728 | 760 | ||
729 | Moves match guard into match arm body. | 761 | Moves match guard into match arm body. |
730 | 762 | ||
@@ -755,6 +787,7 @@ fn handle(action: Action) { | |||
755 | 787 | ||
756 | [discrete] | 788 | [discrete] |
757 | === `remove_dbg` | 789 | === `remove_dbg` |
790 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/remove_dbg.rs#L8[remove_dbg.rs] | ||
758 | 791 | ||
759 | Removes `dbg!()` macro call. | 792 | Removes `dbg!()` macro call. |
760 | 793 | ||
@@ -775,6 +808,7 @@ fn main() { | |||
775 | 808 | ||
776 | [discrete] | 809 | [discrete] |
777 | === `remove_hash` | 810 | === `remove_hash` |
811 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/raw_string.rs#L89[raw_string.rs] | ||
778 | 812 | ||
779 | Removes a hash from a raw string literal. | 813 | Removes a hash from a raw string literal. |
780 | 814 | ||
@@ -795,6 +829,7 @@ fn main() { | |||
795 | 829 | ||
796 | [discrete] | 830 | [discrete] |
797 | === `remove_mut` | 831 | === `remove_mut` |
832 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/remove_mut.rs#L5[remove_mut.rs] | ||
798 | 833 | ||
799 | Removes the `mut` keyword. | 834 | Removes the `mut` keyword. |
800 | 835 | ||
@@ -815,6 +850,7 @@ impl Walrus { | |||
815 | 850 | ||
816 | [discrete] | 851 | [discrete] |
817 | === `reorder_fields` | 852 | === `reorder_fields` |
853 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/reorder_fields.rs#L10[reorder_fields.rs] | ||
818 | 854 | ||
819 | Reorder the fields of record literals and record patterns in the same order as in | 855 | Reorder the fields of record literals and record patterns in the same order as in |
820 | the definition. | 856 | the definition. |
@@ -834,6 +870,7 @@ const test: Foo = Foo {foo: 1, bar: 0} | |||
834 | 870 | ||
835 | [discrete] | 871 | [discrete] |
836 | === `replace_if_let_with_match` | 872 | === `replace_if_let_with_match` |
873 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/replace_if_let_with_match.rs#L13[replace_if_let_with_match.rs] | ||
837 | 874 | ||
838 | Replaces `if let` with an else branch with a `match` expression. | 875 | Replaces `if let` with an else branch with a `match` expression. |
839 | 876 | ||
@@ -865,6 +902,7 @@ fn handle(action: Action) { | |||
865 | 902 | ||
866 | [discrete] | 903 | [discrete] |
867 | === `replace_let_with_if_let` | 904 | === `replace_let_with_if_let` |
905 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/replace_let_with_if_let.rs#L14[replace_let_with_if_let.rs] | ||
868 | 906 | ||
869 | Replaces `let` with an `if-let`. | 907 | Replaces `let` with an `if-let`. |
870 | 908 | ||
@@ -892,6 +930,7 @@ fn compute() -> Option<i32> { None } | |||
892 | 930 | ||
893 | [discrete] | 931 | [discrete] |
894 | === `replace_qualified_name_with_use` | 932 | === `replace_qualified_name_with_use` |
933 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/replace_qualified_name_with_use.rs#L6[replace_qualified_name_with_use.rs] | ||
895 | 934 | ||
896 | Adds a use statement for a given fully-qualified name. | 935 | Adds a use statement for a given fully-qualified name. |
897 | 936 | ||
@@ -910,6 +949,7 @@ fn process(map: HashMap<String, String>) {} | |||
910 | 949 | ||
911 | [discrete] | 950 | [discrete] |
912 | === `replace_unwrap_with_match` | 951 | === `replace_unwrap_with_match` |
952 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/replace_unwrap_with_match.rs#L17[replace_unwrap_with_match.rs] | ||
913 | 953 | ||
914 | Replaces `unwrap` a `match` expression. Works for Result and Option. | 954 | Replaces `unwrap` a `match` expression. Works for Result and Option. |
915 | 955 | ||
@@ -937,6 +977,7 @@ fn main() { | |||
937 | 977 | ||
938 | [discrete] | 978 | [discrete] |
939 | === `split_import` | 979 | === `split_import` |
980 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/split_import.rs#L7[split_import.rs] | ||
940 | 981 | ||
941 | Wraps the tail of import into braces. | 982 | Wraps the tail of import into braces. |
942 | 983 | ||
@@ -953,6 +994,7 @@ use std::{collections::HashMap}; | |||
953 | 994 | ||
954 | [discrete] | 995 | [discrete] |
955 | === `unwrap_block` | 996 | === `unwrap_block` |
997 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/unwrap_block.rs#L9[unwrap_block.rs] | ||
956 | 998 | ||
957 | This assist removes if...else, for, while and loop control statements to just keep the body. | 999 | This assist removes if...else, for, while and loop control statements to just keep the body. |
958 | 1000 | ||
diff --git a/docs/user/generated_features.adoc b/docs/user/generated_features.adoc index 803073d55..12812fa0b 100644 --- a/docs/user/generated_features.adoc +++ b/docs/user/generated_features.adoc | |||
@@ -1,5 +1,5 @@ | |||
1 | === Expand Macro Recursively | 1 | === Expand Macro Recursively |
2 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/expand_macro.rs[expand_macro.rs] | 2 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/expand_macro.rs#L15[expand_macro.rs] |
3 | 3 | ||
4 | Shows the full macro expansion of the macro at current cursor. | 4 | Shows the full macro expansion of the macro at current cursor. |
5 | 5 | ||
@@ -11,7 +11,7 @@ Shows the full macro expansion of the macro at current cursor. | |||
11 | 11 | ||
12 | 12 | ||
13 | === Extend Selection | 13 | === Extend Selection |
14 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/extend_selection.rs[extend_selection.rs] | 14 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/extend_selection.rs#L15[extend_selection.rs] |
15 | 15 | ||
16 | Extends the current selection to the encompassing syntactic construct | 16 | Extends the current selection to the encompassing syntactic construct |
17 | (expression, statement, item, module, etc). It works with multiple cursors. | 17 | (expression, statement, item, module, etc). It works with multiple cursors. |
@@ -24,7 +24,7 @@ Extends the current selection to the encompassing syntactic construct | |||
24 | 24 | ||
25 | 25 | ||
26 | === File Structure | 26 | === File Structure |
27 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/display/structure.rs[structure.rs] | 27 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/display/structure.rs#L17[structure.rs] |
28 | 28 | ||
29 | Provides a tree of the symbols defined in the file. Can be used to | 29 | Provides a tree of the symbols defined in the file. Can be used to |
30 | 30 | ||
@@ -40,7 +40,7 @@ Provides a tree of the symbols defined in the file. Can be used to | |||
40 | 40 | ||
41 | 41 | ||
42 | === Go to Definition | 42 | === Go to Definition |
43 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/goto_definition.rs[goto_definition.rs] | 43 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/goto_definition.rs#L18[goto_definition.rs] |
44 | 44 | ||
45 | Navigates to the definition of an identifier. | 45 | Navigates to the definition of an identifier. |
46 | 46 | ||
@@ -52,7 +52,7 @@ Navigates to the definition of an identifier. | |||
52 | 52 | ||
53 | 53 | ||
54 | === Go to Implementation | 54 | === Go to Implementation |
55 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/goto_implementation.rs[goto_implementation.rs] | 55 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/goto_implementation.rs#L7[goto_implementation.rs] |
56 | 56 | ||
57 | Navigates to the impl block of structs, enums or traits. Also implemented as a code lens. | 57 | Navigates to the impl block of structs, enums or traits. Also implemented as a code lens. |
58 | 58 | ||
@@ -64,7 +64,7 @@ Navigates to the impl block of structs, enums or traits. Also implemented as a c | |||
64 | 64 | ||
65 | 65 | ||
66 | === Go to Type Definition | 66 | === Go to Type Definition |
67 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/goto_type_definition.rs[goto_type_definition.rs] | 67 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/goto_type_definition.rs#L6[goto_type_definition.rs] |
68 | 68 | ||
69 | Navigates to the type of an identifier. | 69 | Navigates to the type of an identifier. |
70 | 70 | ||
@@ -76,14 +76,14 @@ Navigates to the type of an identifier. | |||
76 | 76 | ||
77 | 77 | ||
78 | === Hover | 78 | === Hover |
79 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/hover.rs[hover.rs] | 79 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/hover.rs#L63[hover.rs] |
80 | 80 | ||
81 | Shows additional information, like type of an expression or documentation for definition when "focusing" code. | 81 | Shows additional information, like type of an expression or documentation for definition when "focusing" code. |
82 | Focusing is usually hovering with a mouse, but can also be triggered with a shortcut. | 82 | Focusing is usually hovering with a mouse, but can also be triggered with a shortcut. |
83 | 83 | ||
84 | 84 | ||
85 | === Inlay Hints | 85 | === Inlay Hints |
86 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/inlay_hints.rs[inlay_hints.rs] | 86 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/inlay_hints.rs#L40[inlay_hints.rs] |
87 | 87 | ||
88 | rust-analyzer shows additional information inline with the source code. | 88 | rust-analyzer shows additional information inline with the source code. |
89 | Editors usually render this using read-only virtual text snippets interspersed with code. | 89 | Editors usually render this using read-only virtual text snippets interspersed with code. |
@@ -106,7 +106,7 @@ https://github.com/rust-analyzer/rust-analyzer/issues/1623[1], https://github.co | |||
106 | 106 | ||
107 | 107 | ||
108 | === Join Lines | 108 | === Join Lines |
109 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/join_lines.rs[join_lines.rs] | 109 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/join_lines.rs#L12[join_lines.rs] |
110 | 110 | ||
111 | Join selected lines into one, smartly fixing up whitespace, trailing commas, and braces. | 111 | Join selected lines into one, smartly fixing up whitespace, trailing commas, and braces. |
112 | 112 | ||
@@ -118,7 +118,7 @@ Join selected lines into one, smartly fixing up whitespace, trailing commas, and | |||
118 | 118 | ||
119 | 119 | ||
120 | === Magic Completions | 120 | === Magic Completions |
121 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/completion.rs[completion.rs] | 121 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/completion.rs#L38[completion.rs] |
122 | 122 | ||
123 | In addition to usual reference completion, rust-analyzer provides some ✨magic✨ | 123 | In addition to usual reference completion, rust-analyzer provides some ✨magic✨ |
124 | completions as well: | 124 | completions as well: |
@@ -163,7 +163,7 @@ mod tests { | |||
163 | 163 | ||
164 | 164 | ||
165 | === Matching Brace | 165 | === Matching Brace |
166 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/matching_brace.rs[matching_brace.rs] | 166 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/matching_brace.rs#L3[matching_brace.rs] |
167 | 167 | ||
168 | If the cursor is on any brace (`<>(){}[]`) which is a part of a brace-pair, | 168 | If the cursor is on any brace (`<>(){}[]`) which is a part of a brace-pair, |
169 | moves cursor to the matching brace. It uses the actual parser to determine | 169 | moves cursor to the matching brace. It uses the actual parser to determine |
@@ -177,7 +177,7 @@ braces, so it won't confuse generics with comparisons. | |||
177 | 177 | ||
178 | 178 | ||
179 | === On Typing Assists | 179 | === On Typing Assists |
180 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/typing.rs[typing.rs] | 180 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/typing.rs#L35[typing.rs] |
181 | 181 | ||
182 | Some features trigger on typing certain characters: | 182 | Some features trigger on typing certain characters: |
183 | 183 | ||
@@ -187,7 +187,7 @@ Some features trigger on typing certain characters: | |||
187 | 187 | ||
188 | 188 | ||
189 | === Parent Module | 189 | === Parent Module |
190 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/parent_module.rs[parent_module.rs] | 190 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/parent_module.rs#L12[parent_module.rs] |
191 | 191 | ||
192 | Navigates to the parent module of the current module. | 192 | Navigates to the parent module of the current module. |
193 | 193 | ||
@@ -199,7 +199,7 @@ Navigates to the parent module of the current module. | |||
199 | 199 | ||
200 | 200 | ||
201 | === Run | 201 | === Run |
202 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/runnables.rs[runnables.rs] | 202 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/runnables.rs#L45[runnables.rs] |
203 | 203 | ||
204 | Shows a popup suggesting to run a test/benchmark/binary **at the current cursor | 204 | Shows a popup suggesting to run a test/benchmark/binary **at the current cursor |
205 | location**. Super useful for repeatedly running just a single test. Do bind this | 205 | location**. Super useful for repeatedly running just a single test. Do bind this |
@@ -213,7 +213,7 @@ to a shortcut! | |||
213 | 213 | ||
214 | 214 | ||
215 | === Semantic Syntax Highlighting | 215 | === Semantic Syntax Highlighting |
216 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/syntax_highlighting.rs[syntax_highlighting.rs] | 216 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/syntax_highlighting.rs#L33[syntax_highlighting.rs] |
217 | 217 | ||
218 | rust-analyzer highlights the code semantically. | 218 | rust-analyzer highlights the code semantically. |
219 | For example, `bar` in `foo::Bar` might be colored differently depending on whether `Bar` is an enum or a trait. | 219 | For example, `bar` in `foo::Bar` might be colored differently depending on whether `Bar` is an enum or a trait. |
@@ -225,7 +225,7 @@ We also give special modifier for `mut` and `&mut` local variables. | |||
225 | 225 | ||
226 | 226 | ||
227 | === Show Syntax Tree | 227 | === Show Syntax Tree |
228 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/syntax_tree.rs[syntax_tree.rs] | 228 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/syntax_tree.rs#L9[syntax_tree.rs] |
229 | 229 | ||
230 | Shows the parse tree of the current file. It exists mostly for debugging | 230 | Shows the parse tree of the current file. It exists mostly for debugging |
231 | rust-analyzer itself. | 231 | rust-analyzer itself. |
@@ -238,7 +238,7 @@ rust-analyzer itself. | |||
238 | 238 | ||
239 | 239 | ||
240 | === Status | 240 | === Status |
241 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/status.rs[status.rs] | 241 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/status.rs#L27[status.rs] |
242 | 242 | ||
243 | Shows internal statistic about memory usage of rust-analyzer. | 243 | Shows internal statistic about memory usage of rust-analyzer. |
244 | 244 | ||
@@ -250,7 +250,7 @@ Shows internal statistic about memory usage of rust-analyzer. | |||
250 | 250 | ||
251 | 251 | ||
252 | === Structural Seach and Replace | 252 | === Structural Seach and Replace |
253 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/ssr.rs[ssr.rs] | 253 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/ssr.rs#L26[ssr.rs] |
254 | 254 | ||
255 | Search and replace with named wildcards that will match any expression. | 255 | Search and replace with named wildcards that will match any expression. |
256 | The syntax for a structural search replace command is `<search_pattern> ==>> <replace_pattern>`. | 256 | The syntax for a structural search replace command is `<search_pattern> ==>> <replace_pattern>`. |
@@ -275,7 +275,7 @@ String::from((y + 5).foo(z)) | |||
275 | 275 | ||
276 | 276 | ||
277 | === Workspace Symbol | 277 | === Workspace Symbol |
278 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide_db/src/symbol_index.rs[symbol_index.rs] | 278 | **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide_db/src/symbol_index.rs#L113[symbol_index.rs] |
279 | 279 | ||
280 | Uses fuzzy-search to find types, modules and functions by name across your | 280 | Uses fuzzy-search to find types, modules and functions by name across your |
281 | project and dependencies. This is **the** most useful feature, which improves code | 281 | project and dependencies. This is **the** most useful feature, which improves code |
diff --git a/xtask/src/codegen.rs b/xtask/src/codegen.rs index f3917a244..5511c01d5 100644 --- a/xtask/src/codegen.rs +++ b/xtask/src/codegen.rs | |||
@@ -61,18 +61,18 @@ fn update(path: &Path, contents: &str, mode: Mode) -> Result<()> { | |||
61 | } | 61 | } |
62 | 62 | ||
63 | fn extract_comment_blocks(text: &str) -> Vec<Vec<String>> { | 63 | fn extract_comment_blocks(text: &str) -> Vec<Vec<String>> { |
64 | do_extract_comment_blocks(text, false) | 64 | do_extract_comment_blocks(text, false).into_iter().map(|(_line, block)| block).collect() |
65 | } | 65 | } |
66 | 66 | ||
67 | fn extract_comment_blocks_with_empty_lines(tag: &str, text: &str) -> Vec<CommentBlock> { | 67 | fn extract_comment_blocks_with_empty_lines(tag: &str, text: &str) -> Vec<CommentBlock> { |
68 | assert!(tag.starts_with(char::is_uppercase)); | 68 | assert!(tag.starts_with(char::is_uppercase)); |
69 | let tag = format!("{}:", tag); | 69 | let tag = format!("{}:", tag); |
70 | let mut res = Vec::new(); | 70 | let mut res = Vec::new(); |
71 | for mut block in do_extract_comment_blocks(text, true) { | 71 | for (line, mut block) in do_extract_comment_blocks(text, true) { |
72 | let first = block.remove(0); | 72 | let first = block.remove(0); |
73 | if first.starts_with(&tag) { | 73 | if first.starts_with(&tag) { |
74 | let id = first[tag.len()..].trim().to_string(); | 74 | let id = first[tag.len()..].trim().to_string(); |
75 | let block = CommentBlock { id, contents: block }; | 75 | let block = CommentBlock { id, line, contents: block }; |
76 | res.push(block); | 76 | res.push(block); |
77 | } | 77 | } |
78 | } | 78 | } |
@@ -81,31 +81,38 @@ fn extract_comment_blocks_with_empty_lines(tag: &str, text: &str) -> Vec<Comment | |||
81 | 81 | ||
82 | struct CommentBlock { | 82 | struct CommentBlock { |
83 | id: String, | 83 | id: String, |
84 | line: usize, | ||
84 | contents: Vec<String>, | 85 | contents: Vec<String>, |
85 | } | 86 | } |
86 | 87 | ||
87 | fn do_extract_comment_blocks(text: &str, allow_blocks_with_empty_lines: bool) -> Vec<Vec<String>> { | 88 | fn do_extract_comment_blocks( |
89 | text: &str, | ||
90 | allow_blocks_with_empty_lines: bool, | ||
91 | ) -> Vec<(usize, Vec<String>)> { | ||
88 | let mut res = Vec::new(); | 92 | let mut res = Vec::new(); |
89 | 93 | ||
90 | let prefix = "// "; | 94 | let prefix = "// "; |
91 | let lines = text.lines().map(str::trim_start); | 95 | let lines = text.lines().map(str::trim_start); |
92 | 96 | ||
93 | let mut block = vec![]; | 97 | let mut block = (0, vec![]); |
94 | for line in lines { | 98 | for (line_num, line) in lines.enumerate() { |
95 | if line == "//" && allow_blocks_with_empty_lines { | 99 | if line == "//" && allow_blocks_with_empty_lines { |
96 | block.push(String::new()); | 100 | block.1.push(String::new()); |
97 | continue; | 101 | continue; |
98 | } | 102 | } |
99 | 103 | ||
100 | let is_comment = line.starts_with(prefix); | 104 | let is_comment = line.starts_with(prefix); |
101 | if is_comment { | 105 | if is_comment { |
102 | block.push(line[prefix.len()..].to_string()); | 106 | block.1.push(line[prefix.len()..].to_string()); |
103 | } else if !block.is_empty() { | 107 | } else { |
104 | res.push(mem::replace(&mut block, Vec::new())); | 108 | if !block.1.is_empty() { |
109 | res.push(mem::take(&mut block)); | ||
110 | } | ||
111 | block.0 = line_num + 2; | ||
105 | } | 112 | } |
106 | } | 113 | } |
107 | if !block.is_empty() { | 114 | if !block.1.is_empty() { |
108 | res.push(mem::replace(&mut block, Vec::new())) | 115 | res.push(block) |
109 | } | 116 | } |
110 | res | 117 | res |
111 | } | 118 | } |
@@ -113,11 +120,12 @@ fn do_extract_comment_blocks(text: &str, allow_blocks_with_empty_lines: bool) -> | |||
113 | #[derive(Debug)] | 120 | #[derive(Debug)] |
114 | struct Location { | 121 | struct Location { |
115 | file: PathBuf, | 122 | file: PathBuf, |
123 | line: usize, | ||
116 | } | 124 | } |
117 | 125 | ||
118 | impl Location { | 126 | impl Location { |
119 | fn new(file: PathBuf) -> Self { | 127 | fn new(file: PathBuf, line: usize) -> Self { |
120 | Self { file } | 128 | Self { file, line } |
121 | } | 129 | } |
122 | } | 130 | } |
123 | 131 | ||
@@ -128,8 +136,9 @@ impl fmt::Display for Location { | |||
128 | let name = self.file.file_name().unwrap(); | 136 | let name = self.file.file_name().unwrap(); |
129 | write!( | 137 | write!( |
130 | f, | 138 | f, |
131 | "https://github.com/rust-analyzer/rust-analyzer/blob/master/{}[{}]", | 139 | "https://github.com/rust-analyzer/rust-analyzer/blob/master/{}#L{}[{}]", |
132 | path, | 140 | path, |
141 | self.line, | ||
133 | name.to_str().unwrap() | 142 | name.to_str().unwrap() |
134 | ) | 143 | ) |
135 | } | 144 | } |
diff --git a/xtask/src/codegen/gen_assists_docs.rs b/xtask/src/codegen/gen_assists_docs.rs index 15a02d317..6c1be5350 100644 --- a/xtask/src/codegen/gen_assists_docs.rs +++ b/xtask/src/codegen/gen_assists_docs.rs | |||
@@ -64,7 +64,7 @@ impl Assist { | |||
64 | assert_eq!(lines.next().unwrap().as_str(), "->"); | 64 | assert_eq!(lines.next().unwrap().as_str(), "->"); |
65 | assert_eq!(lines.next().unwrap().as_str(), "```"); | 65 | assert_eq!(lines.next().unwrap().as_str(), "```"); |
66 | let after = take_until(lines.by_ref(), "```"); | 66 | let after = take_until(lines.by_ref(), "```"); |
67 | let location = Location::new(path.to_path_buf()); | 67 | let location = Location::new(path.to_path_buf(), block.line); |
68 | acc.push(Assist { id, location, doc, before, after }) | 68 | acc.push(Assist { id, location, doc, before, after }) |
69 | } | 69 | } |
70 | 70 | ||
@@ -90,6 +90,7 @@ impl fmt::Display for Assist { | |||
90 | writeln!( | 90 | writeln!( |
91 | f, | 91 | f, |
92 | "[discrete]\n=== `{}` | 92 | "[discrete]\n=== `{}` |
93 | **Source:** {} | ||
93 | 94 | ||
94 | {} | 95 | {} |
95 | 96 | ||
@@ -101,6 +102,7 @@ impl fmt::Display for Assist { | |||
101 | ```rust | 102 | ```rust |
102 | {}```", | 103 | {}```", |
103 | self.id, | 104 | self.id, |
105 | self.location, | ||
104 | self.doc, | 106 | self.doc, |
105 | hide_hash_comments(&before), | 107 | hide_hash_comments(&before), |
106 | hide_hash_comments(&after) | 108 | hide_hash_comments(&after) |
diff --git a/xtask/src/codegen/gen_feature_docs.rs b/xtask/src/codegen/gen_feature_docs.rs index 731e7ecf2..31bc3839d 100644 --- a/xtask/src/codegen/gen_feature_docs.rs +++ b/xtask/src/codegen/gen_feature_docs.rs | |||
@@ -40,7 +40,8 @@ impl Feature { | |||
40 | let id = block.id; | 40 | let id = block.id; |
41 | assert!(is_valid_feature_name(&id), "invalid feature name: {:?}", id); | 41 | assert!(is_valid_feature_name(&id), "invalid feature name: {:?}", id); |
42 | let doc = block.contents.join("\n"); | 42 | let doc = block.contents.join("\n"); |
43 | acc.push(Feature { id, location: Location::new(path.clone()), doc }) | 43 | let location = Location::new(path.clone(), block.line); |
44 | acc.push(Feature { id, location, doc }) | ||
44 | } | 45 | } |
45 | 46 | ||
46 | Ok(()) | 47 | Ok(()) |