mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-15 01:17:27 +00:00
runnables => match_ast!
This commit is contained in:
parent
78f93c8033
commit
4ad37df223
1 changed files with 7 additions and 7 deletions
|
@ -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 },
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue