use crate::{
bump::BumpFragment,
token::token::{Token, TokenKind},
};
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct UnresolvedShapeIdentifier<'bump> {
pub namespace: Vec<BumpFragment<'bump>>,
pub name: BumpFragment<'bump>,
pub alias: Option<BumpFragment<'bump>>,
}
impl<'bump> UnresolvedShapeIdentifier<'bump> {
pub fn new(namespace: Vec<BumpFragment<'bump>>, name: BumpFragment<'bump>) -> Self {
Self {
namespace,
name,
alias: None,
}
}
pub fn with_alias(mut self, alias: BumpFragment<'bump>) -> Self {
self.alias = Some(alias);
self
}
pub fn effective_name(&self) -> &str {
self.alias.as_ref().map(|a| a.text()).unwrap_or_else(|| self.name.text())
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct UnqualifiedIdentifier<'bump> {
pub token: Token<'bump>,
}
impl<'bump> UnqualifiedIdentifier<'bump> {
pub fn new(token: Token<'bump>) -> Self {
Self {
token,
}
}
pub fn from_fragment(fragment: BumpFragment<'bump>) -> Self {
Self {
token: Token {
kind: TokenKind::Identifier,
fragment,
},
}
}
pub fn text(&self) -> &str {
self.token.fragment.text()
}
pub fn fragment(&self) -> &BumpFragment<'bump> {
&self.token.fragment
}
pub fn into_fragment(self) -> BumpFragment<'bump> {
self.token.fragment
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct MaybeQualifiedNamespaceIdentifier<'bump> {
pub segments: Vec<BumpFragment<'bump>>,
}
impl<'bump> MaybeQualifiedNamespaceIdentifier<'bump> {
pub fn new(segments: Vec<BumpFragment<'bump>>) -> Self {
Self {
segments,
}
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct MaybeQualifiedTableIdentifier<'bump> {
pub namespace: Vec<BumpFragment<'bump>>,
pub name: BumpFragment<'bump>,
pub alias: Option<BumpFragment<'bump>>,
}
impl<'bump> MaybeQualifiedTableIdentifier<'bump> {
pub fn new(name: BumpFragment<'bump>) -> Self {
Self {
namespace: Vec::new(),
name,
alias: None,
}
}
pub fn with_namespace(mut self, namespace: Vec<BumpFragment<'bump>>) -> Self {
self.namespace = namespace;
self
}
pub fn with_alias(mut self, alias: BumpFragment<'bump>) -> Self {
self.alias = Some(alias);
self
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct MaybeQualifiedDeferredViewIdentifier<'bump> {
pub namespace: Vec<BumpFragment<'bump>>,
pub name: BumpFragment<'bump>,
pub alias: Option<BumpFragment<'bump>>,
}
impl<'bump> MaybeQualifiedDeferredViewIdentifier<'bump> {
pub fn new(name: BumpFragment<'bump>) -> Self {
Self {
namespace: Vec::new(),
name,
alias: None,
}
}
pub fn with_namespace(mut self, namespace: Vec<BumpFragment<'bump>>) -> Self {
self.namespace = namespace;
self
}
pub fn with_alias(mut self, alias: BumpFragment<'bump>) -> Self {
self.alias = Some(alias);
self
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct MaybeQualifiedTransactionalViewIdentifier<'bump> {
pub namespace: Vec<BumpFragment<'bump>>,
pub name: BumpFragment<'bump>,
pub alias: Option<BumpFragment<'bump>>,
}
impl<'bump> MaybeQualifiedTransactionalViewIdentifier<'bump> {
pub fn new(name: BumpFragment<'bump>) -> Self {
Self {
namespace: Vec::new(),
name,
alias: None,
}
}
pub fn with_namespace(mut self, namespace: Vec<BumpFragment<'bump>>) -> Self {
self.namespace = namespace;
self
}
pub fn with_alias(mut self, alias: BumpFragment<'bump>) -> Self {
self.alias = Some(alias);
self
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct MaybeQualifiedViewIdentifier<'bump> {
pub namespace: Vec<BumpFragment<'bump>>,
pub name: BumpFragment<'bump>,
pub alias: Option<BumpFragment<'bump>>,
}
impl<'bump> MaybeQualifiedViewIdentifier<'bump> {
pub fn new(name: BumpFragment<'bump>) -> Self {
Self {
namespace: Vec::new(),
name,
alias: None,
}
}
pub fn with_namespace(mut self, namespace: Vec<BumpFragment<'bump>>) -> Self {
self.namespace = namespace;
self
}
pub fn with_alias(mut self, alias: BumpFragment<'bump>) -> Self {
self.alias = Some(alias);
self
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct MaybeQualifiedRingBufferIdentifier<'bump> {
pub namespace: Vec<BumpFragment<'bump>>,
pub name: BumpFragment<'bump>,
pub alias: Option<BumpFragment<'bump>>,
}
impl<'bump> MaybeQualifiedRingBufferIdentifier<'bump> {
pub fn new(name: BumpFragment<'bump>) -> Self {
Self {
namespace: Vec::new(),
name,
alias: None,
}
}
pub fn with_namespace(mut self, namespace: Vec<BumpFragment<'bump>>) -> Self {
self.namespace = namespace;
self
}
pub fn with_alias(mut self, alias: BumpFragment<'bump>) -> Self {
self.alias = Some(alias);
self
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct MaybeQualifiedDictionaryIdentifier<'bump> {
pub namespace: Vec<BumpFragment<'bump>>,
pub name: BumpFragment<'bump>,
}
impl<'bump> MaybeQualifiedDictionaryIdentifier<'bump> {
pub fn new(name: BumpFragment<'bump>) -> Self {
Self {
namespace: Vec::new(),
name,
}
}
pub fn with_namespace(mut self, namespace: Vec<BumpFragment<'bump>>) -> Self {
self.namespace = namespace;
self
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct MaybeQualifiedSumTypeIdentifier<'bump> {
pub namespace: Vec<BumpFragment<'bump>>,
pub name: BumpFragment<'bump>,
}
impl<'bump> MaybeQualifiedSumTypeIdentifier<'bump> {
pub fn new(name: BumpFragment<'bump>) -> Self {
Self {
namespace: Vec::new(),
name,
}
}
pub fn with_namespace(mut self, namespace: Vec<BumpFragment<'bump>>) -> Self {
self.namespace = namespace;
self
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct MaybeQualifiedSeriesIdentifier<'bump> {
pub namespace: Vec<BumpFragment<'bump>>,
pub name: BumpFragment<'bump>,
}
impl<'bump> MaybeQualifiedSeriesIdentifier<'bump> {
pub fn new(name: BumpFragment<'bump>) -> Self {
Self {
namespace: Vec::new(),
name,
}
}
pub fn with_namespace(mut self, namespace: Vec<BumpFragment<'bump>>) -> Self {
self.namespace = namespace;
self
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct MaybeQualifiedSequenceIdentifier<'bump> {
pub namespace: Vec<BumpFragment<'bump>>,
pub name: BumpFragment<'bump>,
}
impl<'bump> MaybeQualifiedSequenceIdentifier<'bump> {
pub fn new(name: BumpFragment<'bump>) -> Self {
Self {
namespace: Vec::new(),
name,
}
}
pub fn with_namespace(mut self, namespace: Vec<BumpFragment<'bump>>) -> Self {
self.namespace = namespace;
self
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct MaybeQualifiedIndexIdentifier<'bump> {
pub namespace: Vec<BumpFragment<'bump>>,
pub table: BumpFragment<'bump>,
pub name: BumpFragment<'bump>,
}
impl<'bump> MaybeQualifiedIndexIdentifier<'bump> {
pub fn new(table: BumpFragment<'bump>, name: BumpFragment<'bump>) -> Self {
Self {
namespace: Vec::new(),
table,
name,
}
}
pub fn with_shape(mut self, namespace: Vec<BumpFragment<'bump>>) -> Self {
self.namespace = namespace;
self
}
}
#[derive(Debug, Clone, PartialEq)]
pub enum MaybeQualifiedColumnShape<'bump> {
Qualified {
namespace: Vec<BumpFragment<'bump>>,
name: BumpFragment<'bump>,
},
Alias(BumpFragment<'bump>),
Unqualified,
}
#[derive(Debug, Clone, PartialEq)]
pub struct MaybeQualifiedColumnIdentifier<'bump> {
pub shape: MaybeQualifiedColumnShape<'bump>,
pub name: BumpFragment<'bump>,
}
impl<'bump> MaybeQualifiedColumnIdentifier<'bump> {
pub fn unqualified(name: BumpFragment<'bump>) -> Self {
Self {
shape: MaybeQualifiedColumnShape::Unqualified,
name,
}
}
pub fn with_shape(
namespace: Vec<BumpFragment<'bump>>,
shape: BumpFragment<'bump>,
name: BumpFragment<'bump>,
) -> Self {
Self {
shape: MaybeQualifiedColumnShape::Qualified {
namespace,
name: shape,
},
name,
}
}
pub fn with_alias(alias: BumpFragment<'bump>, name: BumpFragment<'bump>) -> Self {
Self {
shape: MaybeQualifiedColumnShape::Alias(alias),
name,
}
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct MaybeQualifiedFunctionIdentifier<'bump> {
pub namespaces: Vec<BumpFragment<'bump>>,
pub name: BumpFragment<'bump>,
}
impl<'bump> MaybeQualifiedFunctionIdentifier<'bump> {
pub fn new(name: BumpFragment<'bump>) -> Self {
Self {
namespaces: Vec::new(),
name,
}
}
pub fn with_namespaces(mut self, namespaces: Vec<BumpFragment<'bump>>) -> Self {
self.namespaces = namespaces;
self
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct MaybeQualifiedProcedureIdentifier<'bump> {
pub namespace: Vec<BumpFragment<'bump>>,
pub name: BumpFragment<'bump>,
}
impl<'bump> MaybeQualifiedProcedureIdentifier<'bump> {
pub fn new(name: BumpFragment<'bump>) -> Self {
Self {
namespace: Vec::new(),
name,
}
}
pub fn with_namespace(mut self, namespace: Vec<BumpFragment<'bump>>) -> Self {
self.namespace = namespace;
self
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct MaybeQualifiedTestIdentifier<'bump> {
pub namespace: Vec<BumpFragment<'bump>>,
pub name: BumpFragment<'bump>,
}
impl<'bump> MaybeQualifiedTestIdentifier<'bump> {
pub fn new(name: BumpFragment<'bump>) -> Self {
Self {
namespace: Vec::new(),
name,
}
}
pub fn with_namespace(mut self, namespace: Vec<BumpFragment<'bump>>) -> Self {
self.namespace = namespace;
self
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct MaybeQualifiedIdentifier<'bump> {
pub namespace: Vec<BumpFragment<'bump>>,
pub name: BumpFragment<'bump>,
}
impl<'bump> MaybeQualifiedIdentifier<'bump> {
pub fn new(name: BumpFragment<'bump>) -> Self {
Self {
namespace: Vec::new(),
name,
}
}
pub fn with_namespace(mut self, namespace: Vec<BumpFragment<'bump>>) -> Self {
self.namespace = namespace;
self
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct MaybeQualifiedSourceIdentifier<'bump> {
pub namespace: Vec<BumpFragment<'bump>>,
pub name: BumpFragment<'bump>,
}
impl<'bump> MaybeQualifiedSourceIdentifier<'bump> {
pub fn new(name: BumpFragment<'bump>) -> Self {
Self {
namespace: Vec::new(),
name,
}
}
pub fn with_namespace(mut self, namespace: Vec<BumpFragment<'bump>>) -> Self {
self.namespace = namespace;
self
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct MaybeQualifiedHandlerIdentifier<'bump> {
pub namespace: Vec<BumpFragment<'bump>>,
pub name: BumpFragment<'bump>,
}
impl<'bump> MaybeQualifiedHandlerIdentifier<'bump> {
pub fn new(name: BumpFragment<'bump>) -> Self {
Self {
namespace: Vec::new(),
name,
}
}
pub fn with_namespace(mut self, namespace: Vec<BumpFragment<'bump>>) -> Self {
self.namespace = namespace;
self
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct MaybeQualifiedSinkIdentifier<'bump> {
pub namespace: Vec<BumpFragment<'bump>>,
pub name: BumpFragment<'bump>,
}
impl<'bump> MaybeQualifiedSinkIdentifier<'bump> {
pub fn new(name: BumpFragment<'bump>) -> Self {
Self {
namespace: Vec::new(),
name,
}
}
pub fn with_namespace(mut self, namespace: Vec<BumpFragment<'bump>>) -> Self {
self.namespace = namespace;
self
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct MaybeQualifiedBindingIdentifier<'bump> {
pub namespace: Vec<BumpFragment<'bump>>,
pub name: BumpFragment<'bump>,
}
impl<'bump> MaybeQualifiedBindingIdentifier<'bump> {
pub fn new(name: BumpFragment<'bump>) -> Self {
Self {
namespace: Vec::new(),
name,
}
}
pub fn with_namespace(mut self, namespace: Vec<BumpFragment<'bump>>) -> Self {
self.namespace = namespace;
self
}
}