squawk_syntax/ast/
nodes.rs1pub use crate::ast::generated::nodes::*;
2use crate::{
3 SyntaxNode,
4 ast::{self, AstNode, support},
5};
6
7#[derive(Debug, Clone, PartialEq, Eq, Hash)]
12pub struct CreateTableLike {
13 pub(crate) syntax: SyntaxNode,
14}
15impl CreateTableLike {
16 #[inline]
17 pub fn path(&self) -> Option<ast::Path> {
18 support::child(&self.syntax)
19 }
20 #[inline]
21 pub fn table_arg_list(&self) -> Option<ast::TableArgList> {
22 support::child(&self.syntax)
23 }
24 #[inline]
25 pub fn inherits(&self) -> Option<ast::Inherits> {
26 support::child(&self.syntax)
27 }
28}
29impl AstNode for CreateTableLike {
30 #[inline]
31 fn can_cast(kind: ast::SyntaxKind) -> bool {
32 matches!(
33 kind,
34 ast::SyntaxKind::CREATE_TABLE | ast::SyntaxKind::CREATE_FOREIGN_TABLE
35 )
36 }
37 #[inline]
38 fn cast(syntax: SyntaxNode) -> Option<Self> {
39 if Self::can_cast(syntax.kind()) {
40 Some(Self { syntax })
41 } else {
42 None
43 }
44 }
45 #[inline]
46 fn syntax(&self) -> &SyntaxNode {
47 &self.syntax
48 }
49}