runnables => match_ast!

This commit is contained in:
kjeremy 2019-10-30 16:09:16 -04:00
parent 78f93c8033
commit 4ad37df223

View file

@ -4,7 +4,7 @@ use itertools::Itertools;
use ra_db::SourceDatabase;
use ra_syntax::{
ast::{self, AstNode, AttrsOwner, ModuleItemOwner, NameOwner},
SyntaxNode, TextRange,
match_ast, SyntaxNode, TextRange,
};
use crate::{db::RootDatabase, FileId};
@ -29,12 +29,12 @@ pub(crate) fn runnables(db: &RootDatabase, file_id: FileId) -> Vec<Runnable> {
}
fn runnable(db: &RootDatabase, file_id: FileId, item: SyntaxNode) -> Option<Runnable> {
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)
} else {
None
match_ast! {
match item {
ast::FnDef(it) => { runnable_fn(it) },
ast::Module(it) => { runnable_mod(db, file_id, it) },
_ => { None },
}
}
}