From f1abc7bdc63fedd5a699b4c495bb23f1b6d254f9 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 19 Jul 2019 12:56:47 +0300 Subject: migrate ra_ide_api to the new rowan --- crates/ra_ide_api/src/runnables.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'crates/ra_ide_api/src/runnables.rs') diff --git a/crates/ra_ide_api/src/runnables.rs b/crates/ra_ide_api/src/runnables.rs index 8cb859b37..200958434 100644 --- a/crates/ra_ide_api/src/runnables.rs +++ b/crates/ra_ide_api/src/runnables.rs @@ -26,8 +26,8 @@ pub(crate) fn runnables(db: &RootDatabase, file_id: FileId) -> Vec { parse.tree().syntax().descendants().filter_map(|i| runnable(db, file_id, i)).collect() } -fn runnable(db: &RootDatabase, file_id: FileId, item: &SyntaxNode) -> Option { - if let Some(fn_def) = ast::FnDef::cast(item) { +fn runnable(db: &RootDatabase, file_id: FileId, item: SyntaxNode) -> Option { + if let Some(fn_def) = ast::FnDef::cast(item.clone()) { runnable_fn(fn_def) } else if let Some(m) = ast::Module::cast(item) { runnable_mod(db, file_id, m) @@ -36,8 +36,8 @@ fn runnable(db: &RootDatabase, file_id: FileId, item: &SyntaxNode) -> Option Option { - let name = fn_def.name()?.text(); +fn runnable_fn(fn_def: ast::FnDef) -> Option { + let name = fn_def.name()?.text().clone(); let kind = if name == "main" { RunnableKind::Bin } else if fn_def.has_atom_attr("test") { @@ -50,7 +50,7 @@ fn runnable_fn(fn_def: &ast::FnDef) -> Option { Some(Runnable { range: fn_def.syntax().range(), kind }) } -fn runnable_mod(db: &RootDatabase, file_id: FileId, module: &ast::Module) -> Option { +fn runnable_mod(db: &RootDatabase, file_id: FileId, module: ast::Module) -> Option { let has_test_function = module .item_list()? .items() -- cgit v1.2.3