cairo_lang_syntax/node/
utils.rsuse super::db::SyntaxGroup;
use super::kind::SyntaxKind;
use super::SyntaxNode;
pub fn is_parent_of_kind(db: &dyn SyntaxGroup, node: &SyntaxNode, kind: SyntaxKind) -> bool {
let Some(parent) = node.parent() else {
return false;
};
parent.kind(db) == kind
}
pub fn is_grandparent_of_kind(db: &dyn SyntaxGroup, node: &SyntaxNode, kind: SyntaxKind) -> bool {
let Some(parent) = node.parent() else {
return false;
};
let Some(grandparent) = parent.parent() else {
return false;
};
grandparent.kind(db) == kind
}
pub fn parent_kind(db: &dyn SyntaxGroup, syntax_node: &SyntaxNode) -> Option<SyntaxKind> {
Some(syntax_node.parent()?.kind(db))
}
pub fn grandparent_kind(db: &dyn SyntaxGroup, syntax_node: &SyntaxNode) -> Option<SyntaxKind> {
Some(syntax_node.parent()?.parent()?.kind(db))
}