From 899570ad7abbc644e87d8379862c1b9f940eaf07 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 31 May 2020 15:36:20 +0200 Subject: Link to the specific source line --- docs/user/generated_assists.adoc | 42 +++++++++++++++++++++++++++++++++++++++ docs/user/generated_features.adoc | 38 +++++++++++++++++------------------ 2 files changed, 61 insertions(+), 19 deletions(-) (limited to 'docs') 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 @@ [discrete] === `add_custom_impl` +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/add_custom_impl.rs#L14[add_custom_impl.rs] Adds impl block for derived trait. @@ -22,6 +23,7 @@ impl Debug for S { [discrete] === `add_derive` +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/add_derive.rs#L9[add_derive.rs] Adds a new `#[derive()]` clause to a struct or enum. @@ -45,6 +47,7 @@ struct Point { [discrete] === `add_explicit_type` +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/add_explicit_type.rs#L9[add_explicit_type.rs] Specify type for a let binding. @@ -65,6 +68,7 @@ fn main() { [discrete] === `add_from_impl_for_enum` +**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] Adds a From impl for an enum variant with one tuple field. @@ -87,6 +91,7 @@ impl From for A { [discrete] === `add_function` +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/add_function.rs#L19[add_function.rs] Adds a stub function with a signature matching the function under the cursor. @@ -117,6 +122,7 @@ fn bar(arg: &str, baz: Baz) { [discrete] === `add_hash` +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/raw_string.rs#L65[raw_string.rs] Adds a hash to a raw string literal. @@ -137,6 +143,7 @@ fn main() { [discrete] === `add_impl` +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/add_impl.rs#L6[add_impl.rs] Adds a new inherent impl for a type. @@ -161,6 +168,7 @@ impl Ctx { [discrete] === `add_impl_default_members` +**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] Adds scaffold for overriding default impl members. @@ -198,6 +206,7 @@ impl Trait for () { [discrete] === `add_impl_missing_members` +**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] Adds scaffold for required impl members. @@ -233,6 +242,7 @@ impl Trait for () { [discrete] === `add_new` +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/add_new.rs#L12[add_new.rs] Adds a new inherent impl for a type. @@ -258,6 +268,7 @@ impl Ctx { [discrete] === `add_turbo_fish` +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/add_turbo_fish.rs#L10[add_turbo_fish.rs] Adds `::<_>` to a call of a generic method or function. @@ -280,6 +291,7 @@ fn main() { [discrete] === `apply_demorgan` +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/apply_demorgan.rs#L5[apply_demorgan.rs] Apply [De Morgan's law](https://en.wikipedia.org/wiki/De_Morgan%27s_laws). This transforms expressions of the form `!l || !r` into `!(l && r)`. @@ -304,6 +316,7 @@ fn main() { [discrete] === `auto_import` +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/auto_import.rs#L18[auto_import.rs] If the name is unresolved, provides all possible imports for it. @@ -326,6 +339,7 @@ fn main() { [discrete] === `change_lifetime_anon_to_named` +**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] Change an anonymous lifetime to a named lifetime. @@ -354,6 +368,7 @@ impl<'a> Cursor<'a> { [discrete] === `change_return_type_to_result` +**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] Change the function's return type to Result. @@ -370,6 +385,7 @@ fn foo() -> Result { Ok(42i32) } [discrete] === `change_visibility` +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/change_visibility.rs#L14[change_visibility.rs] Adds or changes existing visibility specifier. @@ -386,6 +402,7 @@ pub(crate) fn frobnicate() {} [discrete] === `convert_to_guarded_return` +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/early_return.rs#L21[early_return.rs] Replace a large conditional with a guarded return. @@ -413,6 +430,7 @@ fn main() { [discrete] === `fill_match_arms` +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/fill_match_arms.rs#L14[fill_match_arms.rs] Adds missing clauses to a `match` expression. @@ -442,6 +460,7 @@ fn handle(action: Action) { [discrete] === `fix_visibility` +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/fix_visibility.rs#L13[fix_visibility.rs] Makes inaccessible item public. @@ -468,6 +487,7 @@ fn main() { [discrete] === `flip_binexpr` +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/flip_binexpr.rs#L5[flip_binexpr.rs] Flips operands of a binary expression. @@ -488,6 +508,7 @@ fn main() { [discrete] === `flip_comma` +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/flip_comma.rs#L5[flip_comma.rs] Flips two comma-separated items. @@ -508,6 +529,7 @@ fn main() { [discrete] === `flip_trait_bound` +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/flip_trait_bound.rs#L9[flip_trait_bound.rs] Flips two trait bounds. @@ -524,6 +546,7 @@ fn foo() { } [discrete] === `inline_local_variable` +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/inline_local_variable.rs#L13[inline_local_variable.rs] Inlines local variable. @@ -545,6 +568,7 @@ fn main() { [discrete] === `introduce_variable` +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/introduce_variable.rs#L14[introduce_variable.rs] Extracts subexpression into a variable. @@ -566,6 +590,7 @@ fn main() { [discrete] === `invert_if` +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/invert_if.rs#L12[invert_if.rs] Apply invert_if This transforms if expressions of the form `if !x {A} else {B}` into `if x {B} else {A}` @@ -589,6 +614,7 @@ fn main() { [discrete] === `make_raw_string` +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/raw_string.rs#L10[raw_string.rs] Adds `r#` to a plain string literal. @@ -609,6 +635,7 @@ fn main() { [discrete] === `make_usual_string` +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/raw_string.rs#L39[raw_string.rs] Turns a raw string into a plain string. @@ -629,6 +656,7 @@ fn main() { [discrete] === `merge_imports` +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/merge_imports.rs#L14[merge_imports.rs] Merges two imports with a common prefix. @@ -646,6 +674,7 @@ use std::{fmt::Formatter, io}; [discrete] === `merge_match_arms` +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/merge_match_arms.rs#L11[merge_match_arms.rs] Merges identical match arms. @@ -675,6 +704,7 @@ fn handle(action: Action) { [discrete] === `move_arm_cond_to_match_guard` +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/move_guard.rs#L56[move_guard.rs] Moves if expression from match arm body into a guard. @@ -705,6 +735,7 @@ fn handle(action: Action) { [discrete] === `move_bounds_to_where_clause` +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/move_bounds.rs#L10[move_bounds.rs] Moves inline type bounds to a where clause. @@ -725,6 +756,7 @@ fn apply(f: F, x: T) -> U where F: FnOnce(T) -> U { [discrete] === `move_guard_to_arm_body` +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/move_guard.rs#L8[move_guard.rs] Moves match guard into match arm body. @@ -755,6 +787,7 @@ fn handle(action: Action) { [discrete] === `remove_dbg` +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/remove_dbg.rs#L8[remove_dbg.rs] Removes `dbg!()` macro call. @@ -775,6 +808,7 @@ fn main() { [discrete] === `remove_hash` +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/raw_string.rs#L89[raw_string.rs] Removes a hash from a raw string literal. @@ -795,6 +829,7 @@ fn main() { [discrete] === `remove_mut` +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/remove_mut.rs#L5[remove_mut.rs] Removes the `mut` keyword. @@ -815,6 +850,7 @@ impl Walrus { [discrete] === `reorder_fields` +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/reorder_fields.rs#L10[reorder_fields.rs] Reorder the fields of record literals and record patterns in the same order as in the definition. @@ -834,6 +870,7 @@ const test: Foo = Foo {foo: 1, bar: 0} [discrete] === `replace_if_let_with_match` +**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] Replaces `if let` with an else branch with a `match` expression. @@ -865,6 +902,7 @@ fn handle(action: Action) { [discrete] === `replace_let_with_if_let` +**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] Replaces `let` with an `if-let`. @@ -892,6 +930,7 @@ fn compute() -> Option { None } [discrete] === `replace_qualified_name_with_use` +**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] Adds a use statement for a given fully-qualified name. @@ -910,6 +949,7 @@ fn process(map: HashMap) {} [discrete] === `replace_unwrap_with_match` +**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] Replaces `unwrap` a `match` expression. Works for Result and Option. @@ -937,6 +977,7 @@ fn main() { [discrete] === `split_import` +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/split_import.rs#L7[split_import.rs] Wraps the tail of import into braces. @@ -953,6 +994,7 @@ use std::{collections::HashMap}; [discrete] === `unwrap_block` +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_assists/src/handlers/unwrap_block.rs#L9[unwrap_block.rs] This assist removes if...else, for, while and loop control statements to just keep the body. 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 @@ === Expand Macro Recursively -**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/expand_macro.rs[expand_macro.rs] +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/expand_macro.rs#L15[expand_macro.rs] Shows the full macro expansion of the macro at current cursor. @@ -11,7 +11,7 @@ Shows the full macro expansion of the macro at current cursor. === Extend Selection -**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/extend_selection.rs[extend_selection.rs] +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/extend_selection.rs#L15[extend_selection.rs] Extends the current selection to the encompassing syntactic construct (expression, statement, item, module, etc). It works with multiple cursors. @@ -24,7 +24,7 @@ Extends the current selection to the encompassing syntactic construct === File Structure -**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/display/structure.rs[structure.rs] +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/display/structure.rs#L17[structure.rs] Provides a tree of the symbols defined in the file. Can be used to @@ -40,7 +40,7 @@ Provides a tree of the symbols defined in the file. Can be used to === Go to Definition -**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/goto_definition.rs[goto_definition.rs] +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/goto_definition.rs#L18[goto_definition.rs] Navigates to the definition of an identifier. @@ -52,7 +52,7 @@ Navigates to the definition of an identifier. === Go to Implementation -**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/goto_implementation.rs[goto_implementation.rs] +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/goto_implementation.rs#L7[goto_implementation.rs] Navigates to the impl block of structs, enums or traits. Also implemented as a code lens. @@ -64,7 +64,7 @@ Navigates to the impl block of structs, enums or traits. Also implemented as a c === Go to Type Definition -**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/goto_type_definition.rs[goto_type_definition.rs] +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/goto_type_definition.rs#L6[goto_type_definition.rs] Navigates to the type of an identifier. @@ -76,14 +76,14 @@ Navigates to the type of an identifier. === Hover -**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/hover.rs[hover.rs] +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/hover.rs#L63[hover.rs] Shows additional information, like type of an expression or documentation for definition when "focusing" code. Focusing is usually hovering with a mouse, but can also be triggered with a shortcut. === Inlay Hints -**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/inlay_hints.rs[inlay_hints.rs] +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/inlay_hints.rs#L40[inlay_hints.rs] rust-analyzer shows additional information inline with the source code. 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 === Join Lines -**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/join_lines.rs[join_lines.rs] +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/join_lines.rs#L12[join_lines.rs] Join selected lines into one, smartly fixing up whitespace, trailing commas, and braces. @@ -118,7 +118,7 @@ Join selected lines into one, smartly fixing up whitespace, trailing commas, and === Magic Completions -**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/completion.rs[completion.rs] +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/completion.rs#L38[completion.rs] In addition to usual reference completion, rust-analyzer provides some ✨magic✨ completions as well: @@ -163,7 +163,7 @@ mod tests { === Matching Brace -**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/matching_brace.rs[matching_brace.rs] +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/matching_brace.rs#L3[matching_brace.rs] If the cursor is on any brace (`<>(){}[]`) which is a part of a brace-pair, 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. === On Typing Assists -**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/typing.rs[typing.rs] +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/typing.rs#L35[typing.rs] Some features trigger on typing certain characters: @@ -187,7 +187,7 @@ Some features trigger on typing certain characters: === Parent Module -**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/parent_module.rs[parent_module.rs] +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/parent_module.rs#L12[parent_module.rs] Navigates to the parent module of the current module. @@ -199,7 +199,7 @@ Navigates to the parent module of the current module. === Run -**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/runnables.rs[runnables.rs] +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/runnables.rs#L45[runnables.rs] Shows a popup suggesting to run a test/benchmark/binary **at the current cursor location**. Super useful for repeatedly running just a single test. Do bind this @@ -213,7 +213,7 @@ to a shortcut! === Semantic Syntax Highlighting -**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/syntax_highlighting.rs[syntax_highlighting.rs] +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/syntax_highlighting.rs#L33[syntax_highlighting.rs] rust-analyzer highlights the code semantically. 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. === Show Syntax Tree -**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/syntax_tree.rs[syntax_tree.rs] +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/syntax_tree.rs#L9[syntax_tree.rs] Shows the parse tree of the current file. It exists mostly for debugging rust-analyzer itself. @@ -238,7 +238,7 @@ rust-analyzer itself. === Status -**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/status.rs[status.rs] +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/status.rs#L27[status.rs] Shows internal statistic about memory usage of rust-analyzer. @@ -250,7 +250,7 @@ Shows internal statistic about memory usage of rust-analyzer. === Structural Seach and Replace -**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/ssr.rs[ssr.rs] +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/ssr.rs#L26[ssr.rs] Search and replace with named wildcards that will match any expression. The syntax for a structural search replace command is ` ==>> `. @@ -275,7 +275,7 @@ String::from((y + 5).foo(z)) === Workspace Symbol -**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide_db/src/symbol_index.rs[symbol_index.rs] +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide_db/src/symbol_index.rs#L113[symbol_index.rs] Uses fuzzy-search to find types, modules and functions by name across your project and dependencies. This is **the** most useful feature, which improves code -- cgit v1.2.3