Skip to main content

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    #[inline]
20    fn persistence(&self) -> Option<ast::Persistence> {
21        support::child(self.syntax())
22    }
23
24    #[inline]
25    fn inherits(&self) -> Option<ast::Inherits> {
26        support::child(self.syntax())
27    }
28}
29
30pub trait HasWithClause: AstNode {
31    #[inline]
32    fn with_clause(&self) -> Option<ast::WithClause> {
33        support::child(self.syntax())
34    }
35}
36
37pub trait HasParamList: AstNode {
38    fn param_list(&self) -> Option<ast::ParamList> {
39        support::child(self.syntax())
40    }
41}