]> git.lizzy.rs Git - rust.git/commitdiff
Specify actions
authorAleksey Kladov <aleksey.kladov@gmail.com>
Sun, 31 May 2020 07:45:41 +0000 (09:45 +0200)
committerAleksey Kladov <aleksey.kladov@gmail.com>
Sun, 31 May 2020 07:45:41 +0000 (09:45 +0200)
crates/ra_ide/src/goto_definition.rs
crates/ra_ide/src/goto_implementation.rs
crates/ra_ide/src/goto_type_definition.rs
crates/ra_ide/src/runnables.rs
docs/user/features.md
docs/user/generated_features.adoc
xtask/src/codegen/gen_feature_docs.rs

index 83ea5092c81bf4a06fadbac104ad6d78709101a5..daeeac76f637bd9f7c4da0a7a2c9567817177752 100644 (file)
@@ -17,7 +17,7 @@
     FilePosition, NavigationTarget, RangeInfo,
 };
 
-// Feature: Go To Definition
+// Feature: Go to Definition
 //
 // Navigates to the definition of an identifier.
 //
index a5a296d228b9aad685e99502a8d843a3ee330e43..622a094e60019c8893754503e0a9a579aa7eaedb 100644 (file)
@@ -6,7 +6,7 @@
 
 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.
 //
index eeadfa9ee702d767c49be0485b2abecd1f6b0105..e74a502ecb9acba938bfd5205ff3e69e3b5915ec 100644 (file)
@@ -5,9 +5,15 @@
 
 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,
index 6e7e47199c88291aeb43729654798dfd49e260e1..4bf2678e104685171a3d56f3bea95e21517d14da 100644 (file)
@@ -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<Runnable> {
     let sema = Semantics::new(db);
     let source_file = sema.parse(file_id);
index 4d940225249b8c6d3ceee8f3a2d65567c1267568..df8e73a20d5fc400defd7da1617b30eb8b533f8f 100644 (file)
@@ -4,12 +4,6 @@ you can use <kbd>Ctrl+Shift+P</kbd> to search for the corresponding action.
 
 ### Commands <kbd>ctrl+shift+p</kbd>
 
-#### 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.
index e1eb5d88a8f667e20d99d1545b4579b923787f84..1f6fcc97410eb3c7a844704306d1fb316d0946ad 100644 (file)
@@ -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]
 
index 58318564872e88cc459e8b73917186b767ec0846..170a3e88942a7304ce0ab2f07981c4663ca02c4d 100644 (file)
@@ -38,11 +38,7 @@ fn collect_file(acc: &mut Vec<Feature>, path: PathBuf) -> Result<()> {
 
             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 @@ fn collect_file(acc: &mut Vec<Feature>, path: PathBuf) -> Result<()> {
     }
 }
 
+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)?;