diff --git a/crates/ra_ide/src/goto_definition.rs b/crates/ra_ide/src/goto_definition.rs index 83ea5092c81..daeeac76f63 100644 --- a/crates/ra_ide/src/goto_definition.rs +++ b/crates/ra_ide/src/goto_definition.rs @@ -17,7 +17,7 @@ use crate::{ FilePosition, NavigationTarget, RangeInfo, }; -// Feature: Go To Definition +// Feature: Go to Definition // // Navigates to the definition of an identifier. // diff --git a/crates/ra_ide/src/goto_implementation.rs b/crates/ra_ide/src/goto_implementation.rs index a5a296d228b..622a094e600 100644 --- a/crates/ra_ide/src/goto_implementation.rs +++ b/crates/ra_ide/src/goto_implementation.rs @@ -6,7 +6,7 @@ use ra_syntax::{algo::find_node_at_offset, ast, AstNode}; use crate::{display::ToNav, FilePosition, NavigationTarget, RangeInfo}; -// Feature: Go To Implementation +// Feature: Go to Implementation // // Navigates to the impl block of structs, enums or traits. Also implemented as a code lens. // diff --git a/crates/ra_ide/src/goto_type_definition.rs b/crates/ra_ide/src/goto_type_definition.rs index eeadfa9ee70..e74a502ecb9 100644 --- a/crates/ra_ide/src/goto_type_definition.rs +++ b/crates/ra_ide/src/goto_type_definition.rs @@ -5,9 +5,15 @@ use ra_syntax::{ast, match_ast, AstNode, SyntaxKind::*, SyntaxToken, TokenAtOffs use crate::{display::ToNav, FilePosition, NavigationTarget, RangeInfo}; -// Feature: Go To Type Definition +// Feature: Go to Type Definition // // Navigates to the type of an identifier. +// +// |=== +// | Editor | Action Name +// +// | VS Code | **Go to Type Definition* +// |=== pub(crate) fn goto_type_definition( db: &RootDatabase, position: FilePosition, diff --git a/crates/ra_ide/src/runnables.rs b/crates/ra_ide/src/runnables.rs index 6e7e47199c8..4bf2678e104 100644 --- a/crates/ra_ide/src/runnables.rs +++ b/crates/ra_ide/src/runnables.rs @@ -44,6 +44,17 @@ pub enum RunnableKind { Bin, } +// Feature: Run +// +// 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 +// to a shortcut! +// +// |=== +// | Editor | Action Name +// +// | VS Code | **Rust Analyzer: Run** +// |=== pub(crate) fn runnables(db: &RootDatabase, file_id: FileId) -> Vec { let sema = Semantics::new(db); let source_file = sema.parse(file_id); diff --git a/docs/user/features.md b/docs/user/features.md index 4d940225249..df8e73a20d5 100644 --- a/docs/user/features.md +++ b/docs/user/features.md @@ -4,12 +4,6 @@ you can use Ctrl+Shift+P to search for the corresponding action. ### Commands ctrl+shift+p -#### Run - -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 -to a shortcut! - #### Parent Module Navigates to the parent module of the current module. diff --git a/docs/user/generated_features.adoc b/docs/user/generated_features.adoc index e1eb5d88a8f..1f6fcc97410 100644 --- a/docs/user/generated_features.adoc +++ b/docs/user/generated_features.adoc @@ -29,7 +29,7 @@ Provides a tree of the symbols defined in the file. Can be used to |=== -=== Go To Definition +=== Go to Definition **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/goto_definition.rs[goto_definition.rs] @@ -42,7 +42,7 @@ Navigates to the definition of an identifier. |=== -=== Go To Implementation +=== Go to Implementation **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/goto_implementation.rs[goto_implementation.rs] @@ -55,12 +55,18 @@ Navigates to the impl block of structs, enums or traits. Also implemented as a c |=== -=== Go To Type Definition +=== 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] Navigates to the type of an identifier. +|=== +| Editor | Action Name + +| VS Code | **Go to Type Definition* +|=== + === On Typing Assists **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/typing.rs[typing.rs] @@ -73,6 +79,21 @@ Some features trigger on typing certain characters: - typing `.` in a chain method call auto-indents +=== Run +**Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/runnables.rs[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 +to a shortcut! + +|=== +| Editor | Action Name + +| VS Code | **Rust Analyzer: Run** +|=== + + === Workspace Symbol **Source:** https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide_db/src/symbol_index.rs[symbol_index.rs] diff --git a/xtask/src/codegen/gen_feature_docs.rs b/xtask/src/codegen/gen_feature_docs.rs index 58318564872..170a3e88942 100644 --- a/xtask/src/codegen/gen_feature_docs.rs +++ b/xtask/src/codegen/gen_feature_docs.rs @@ -38,11 +38,7 @@ impl Feature { for block in comment_blocks { let id = block.id; - assert!( - id.split_ascii_whitespace().all(|it| it.starts_with(char::is_uppercase)), - "bad feature: {}", - id - ); + assert!(is_valid_feature_name(&id), "invalid feature name: {:?}", id); let doc = block.contents.join("\n"); acc.push(Feature { id, path: path.clone(), doc }) } @@ -52,6 +48,25 @@ impl Feature { } } +fn is_valid_feature_name(feature: &str) -> bool { + 'word: for word in feature.split_whitespace() { + for &short in ["to"].iter() { + if word == short { + continue 'word; + } + } + for &short in ["To"].iter() { + if word == short { + return false; + } + } + if !word.starts_with(char::is_uppercase) { + return false; + } + } + true +} + impl fmt::Display for Feature { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { writeln!(f, "=== {}", self.id)?;