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    fn text(&self) -> String;
8}
9
10pub trait HasCreateTable: AstNode {
11    #[inline]
12    fn path(&self) -> Option<ast::Path> {
13        support::child(self.syntax())
14    }
15
16    #[inline]
17    fn table_arg_list(&self) -> Option<ast::TableArgList> {
18        support::child(self.syntax())
19    }
20
21    #[inline]
22    fn persistence(&self) -> Option<ast::Persistence> {
23        support::child(self.syntax())
24    }
25
26    #[inline]
27    fn inherits(&self) -> Option<ast::Inherits> {
28        support::child(self.syntax())
29    }
30}
31
32pub trait HasWithClause: AstNode {
33    #[inline]
34    fn with_clause(&self) -> Option<ast::WithClause> {
35        support::child(self.syntax())
36    }
37}
38
39pub trait HasParamList: AstNode {
40    fn param_list(&self) -> Option<ast::ParamList> {
41        support::child(self.syntax())
42    }
43}