Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/syntax/src/ast/node_ext.rs')
| -rw-r--r-- | crates/syntax/src/ast/node_ext.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/crates/syntax/src/ast/node_ext.rs b/crates/syntax/src/ast/node_ext.rs index 930e5ce74f..4070406702 100644 --- a/crates/syntax/src/ast/node_ext.rs +++ b/crates/syntax/src/ast/node_ext.rs @@ -796,6 +796,16 @@ impl ast::TokenTree { .into_token() .filter(|it| matches!(it.kind(), T!['}'] | T![')'] | T![']'])) } + + pub fn parent_meta(&self) -> Option<ast::Meta> { + self.syntax().parent().and_then(ast::Meta::cast) + } +} + +impl ast::Meta { + pub fn parent_attr(&self) -> Option<ast::Attr> { + self.syntax().parent().and_then(ast::Attr::cast) + } } impl ast::GenericParamList { |