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 NameLike: AstNode {}
7
8pub trait HasCreateTable: AstNode {
9    #[inline]
10    fn path(&self) -> Option<ast::Path> {
11        support::child(self.syntax())
12    }
13
14    #[inline]
15    fn table_arg_list(&self) -> Option<ast::TableArgList> {
16        support::child(self.syntax())
17    }
18}
19
20pub trait HasWithClause: AstNode {
21    #[inline]
22    fn with_clause(&self) -> Option<ast::WithClause> {
23        support::child(self.syntax())
24    }
25}
26
27pub trait HasParamList: AstNode {
28    fn param_list(&self) -> Option<ast::ParamList> {
29        support::child(self.syntax())
30    }
31}