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 NameLike: AstNode {}
13
14pub trait HasArgList: AstNode {
15    fn arg_list(&self) -> Option<ast::ArgList> {
16        support::child(self.syntax())
17    }
18}
19
20pub trait HasParamList: AstNode {
21    fn param_list(&self) -> Option<ast::ParamList> {
22        support::child(self.syntax())
23    }
24}
25
26pub trait HasIfExists: AstNode {
27    fn if_exists(&self) -> Option<ast::IfExists> {
28        support::child(self.syntax())
29    }
30}
31
32pub trait HasIfNotExists: AstNode {
33    fn if_not_exists(&self) -> Option<ast::IfNotExists> {
34        support::child(self.syntax())
35    }
36}