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