diff options
author | Aleksey Kladov <[email protected]> | 2019-02-08 11:49:43 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-02-08 11:49:43 +0000 |
commit | 12e3b4c70b5ef23b2fdfc197296d483680e125f9 (patch) | |
tree | 71baa0e0a62f9f6b61450501c5f821f67badf9e4 /crates/ra_ide_api/src/runnables.rs | |
parent | 5cb1d41a30d25cbe136402644bf5434dd667f1e5 (diff) |
reformat the world
Diffstat (limited to 'crates/ra_ide_api/src/runnables.rs')
-rw-r--r-- | crates/ra_ide_api/src/runnables.rs | 31 |
1 files changed, 6 insertions, 25 deletions
diff --git a/crates/ra_ide_api/src/runnables.rs b/crates/ra_ide_api/src/runnables.rs index dc8c40ea6..d64b5a4e0 100644 --- a/crates/ra_ide_api/src/runnables.rs +++ b/crates/ra_ide_api/src/runnables.rs | |||
@@ -23,11 +23,7 @@ pub enum RunnableKind { | |||
23 | 23 | ||
24 | pub(crate) fn runnables(db: &RootDatabase, file_id: FileId) -> Vec<Runnable> { | 24 | pub(crate) fn runnables(db: &RootDatabase, file_id: FileId) -> Vec<Runnable> { |
25 | let source_file = db.parse(file_id); | 25 | let source_file = db.parse(file_id); |
26 | source_file | 26 | source_file.syntax().descendants().filter_map(|i| runnable(db, file_id, i)).collect() |
27 | .syntax() | ||
28 | .descendants() | ||
29 | .filter_map(|i| runnable(db, file_id, i)) | ||
30 | .collect() | ||
31 | } | 27 | } |
32 | 28 | ||
33 | fn runnable(db: &RootDatabase, file_id: FileId, item: &SyntaxNode) -> Option<Runnable> { | 29 | fn runnable(db: &RootDatabase, file_id: FileId, item: &SyntaxNode) -> Option<Runnable> { |
@@ -45,20 +41,13 @@ fn runnable_fn(fn_def: &ast::FnDef) -> Option<Runnable> { | |||
45 | let kind = if name == "main" { | 41 | let kind = if name == "main" { |
46 | RunnableKind::Bin | 42 | RunnableKind::Bin |
47 | } else if fn_def.has_atom_attr("test") { | 43 | } else if fn_def.has_atom_attr("test") { |
48 | RunnableKind::Test { | 44 | RunnableKind::Test { name: name.to_string() } |
49 | name: name.to_string(), | ||
50 | } | ||
51 | } else if fn_def.has_atom_attr("bench") { | 45 | } else if fn_def.has_atom_attr("bench") { |
52 | RunnableKind::Bench { | 46 | RunnableKind::Bench { name: name.to_string() } |
53 | name: name.to_string(), | ||
54 | } | ||
55 | } else { | 47 | } else { |
56 | return None; | 48 | return None; |
57 | }; | 49 | }; |
58 | Some(Runnable { | 50 | Some(Runnable { range: fn_def.syntax().range(), kind }) |
59 | range: fn_def.syntax().range(), | ||
60 | kind, | ||
61 | }) | ||
62 | } | 51 | } |
63 | 52 | ||
64 | fn runnable_mod(db: &RootDatabase, file_id: FileId, module: &ast::Module) -> Option<Runnable> { | 53 | fn runnable_mod(db: &RootDatabase, file_id: FileId, module: &ast::Module) -> Option<Runnable> { |
@@ -77,16 +66,8 @@ fn runnable_mod(db: &RootDatabase, file_id: FileId, module: &ast::Module) -> Opt | |||
77 | let module = hir::source_binder::module_from_child_node(db, file_id, module.syntax())?; | 66 | let module = hir::source_binder::module_from_child_node(db, file_id, module.syntax())?; |
78 | 67 | ||
79 | // FIXME: thread cancellation instead of `.ok`ing | 68 | // FIXME: thread cancellation instead of `.ok`ing |
80 | let path = module | 69 | let path = module.path_to_root(db).into_iter().rev().filter_map(|it| it.name(db)).join("::"); |
81 | .path_to_root(db) | 70 | Some(Runnable { range, kind: RunnableKind::TestMod { path } }) |
82 | .into_iter() | ||
83 | .rev() | ||
84 | .filter_map(|it| it.name(db)) | ||
85 | .join("::"); | ||
86 | Some(Runnable { | ||
87 | range, | ||
88 | kind: RunnableKind::TestMod { path }, | ||
89 | }) | ||
90 | } | 71 | } |
91 | 72 | ||
92 | #[cfg(test)] | 73 | #[cfg(test)] |