squawk_syntax/ast/
traits.rs

1// based on rust-analyzer's ast traits
2// https://github.com/rust-lang/rust-analyzer/blob/d8887c0758bbd2d5f752d5bd405d4491e90e7ed6/crates/syntax/src/ast/traits.rs
3use crate::ast;
4use crate::ast::{AstNode, support};
5
6pub trait HasName: AstNode {
7    fn name(&self) -> Option<ast::Name> {
8        support::child(self.syntax())
9    }
10}
11
12pub trait HasArgList: AstNode {
13    fn arg_list(&self) -> Option<ast::ArgList> {
14        support::child(self.syntax())
15    }
16}
17
18pub trait HasIfExists: AstNode {
19    fn if_exists(&self) -> Option<ast::IfExists> {
20        support::child(self.syntax())
21    }
22}
23
24pub trait HasIfNotExists: AstNode {
25    fn if_not_exists(&self) -> Option<ast::IfNotExists> {
26        support::child(self.syntax())
27    }
28}