@@ -323,6 +323,10 @@ pub(crate) enum AncestorType {
323323 TSInstantiationExpressionTypeArguments = 299,
324324 JSDocNullableTypeTypeAnnotation = 300,
325325 JSDocNonNullableTypeTypeAnnotation = 301,
326+ AstroRootFrontmatter = 302,
327+ AstroRootBody = 303,
328+ AstroFrontmatterProgram = 304,
329+ AstroScriptProgram = 305,
326330}
327331
328332/// Ancestor type used in AST traversal.
@@ -907,6 +911,12 @@ pub enum Ancestor<'a, 't> {
907911 AncestorType::JSDocNullableTypeTypeAnnotation as u16,
908912 JSDocNonNullableTypeTypeAnnotation(JSDocNonNullableTypeWithoutTypeAnnotation<'a, 't>) =
909913 AncestorType::JSDocNonNullableTypeTypeAnnotation as u16,
914+ AstroRootFrontmatter(AstroRootWithoutFrontmatter<'a, 't>) =
915+ AncestorType::AstroRootFrontmatter as u16,
916+ AstroRootBody(AstroRootWithoutBody<'a, 't>) = AncestorType::AstroRootBody as u16,
917+ AstroFrontmatterProgram(AstroFrontmatterWithoutProgram<'a, 't>) =
918+ AncestorType::AstroFrontmatterProgram as u16,
919+ AstroScriptProgram(AstroScriptWithoutProgram<'a, 't>) = AncestorType::AstroScriptProgram as u16,
910920}
911921
912922impl<'a, 't> Ancestor<'a, 't> {
@@ -1905,6 +1915,21 @@ impl<'a, 't> Ancestor<'a, 't> {
19051915 matches!(self, Self::JSDocNonNullableTypeTypeAnnotation(_))
19061916 }
19071917
1918+ #[inline]
1919+ pub fn is_astro_root(self) -> bool {
1920+ matches!(self, Self::AstroRootFrontmatter(_) | Self::AstroRootBody(_))
1921+ }
1922+
1923+ #[inline]
1924+ pub fn is_astro_frontmatter(self) -> bool {
1925+ matches!(self, Self::AstroFrontmatterProgram(_))
1926+ }
1927+
1928+ #[inline]
1929+ pub fn is_astro_script(self) -> bool {
1930+ matches!(self, Self::AstroScriptProgram(_))
1931+ }
1932+
19081933 #[inline]
19091934 pub fn is_parent_of_statement(self) -> bool {
19101935 matches!(
@@ -2123,7 +2148,10 @@ impl<'a, 't> Ancestor<'a, 't> {
21232148
21242149 #[inline]
21252150 pub fn is_parent_of_jsx_child(self) -> bool {
2126- matches!(self, Self::JSXElementChildren(_) | Self::JSXFragmentChildren(_))
2151+ matches!(
2152+ self,
2153+ Self::JSXElementChildren(_) | Self::JSXFragmentChildren(_) | Self::AstroRootBody(_)
2154+ )
21272155 }
21282156
21292157 #[inline]
@@ -2559,6 +2587,10 @@ impl<'a, 't> GetAddress for Ancestor<'a, 't> {
25592587 Self::TSInstantiationExpressionTypeArguments(a) => a.address(),
25602588 Self::JSDocNullableTypeTypeAnnotation(a) => a.address(),
25612589 Self::JSDocNonNullableTypeTypeAnnotation(a) => a.address(),
2590+ Self::AstroRootFrontmatter(a) => a.address(),
2591+ Self::AstroRootBody(a) => a.address(),
2592+ Self::AstroFrontmatterProgram(a) => a.address(),
2593+ Self::AstroScriptProgram(a) => a.address(),
25622594 }
25632595 }
25642596}
@@ -18569,3 +18601,112 @@ impl<'a, 't> GetAddress for JSDocNonNullableTypeWithoutTypeAnnotation<'a, 't> {
1856918601 unsafe { Address::from_ptr(self.0) }
1857018602 }
1857118603}
18604+
18605+ pub(crate) const OFFSET_ASTRO_ROOT_SPAN: usize = offset_of!(AstroRoot, span);
18606+ pub(crate) const OFFSET_ASTRO_ROOT_FRONTMATTER: usize = offset_of!(AstroRoot, frontmatter);
18607+ pub(crate) const OFFSET_ASTRO_ROOT_BODY: usize = offset_of!(AstroRoot, body);
18608+
18609+ #[repr(transparent)]
18610+ #[derive(Clone, Copy, Debug)]
18611+ pub struct AstroRootWithoutFrontmatter<'a, 't>(
18612+ pub(crate) *const AstroRoot<'a>,
18613+ pub(crate) PhantomData<&'t ()>,
18614+ );
18615+
18616+ impl<'a, 't> AstroRootWithoutFrontmatter<'a, 't> {
18617+ #[inline]
18618+ pub fn span(self) -> &'t Span {
18619+ unsafe { &*((self.0 as *const u8).add(OFFSET_ASTRO_ROOT_SPAN) as *const Span) }
18620+ }
18621+
18622+ #[inline]
18623+ pub fn body(self) -> &'t Vec<'a, JSXChild<'a>> {
18624+ unsafe {
18625+ &*((self.0 as *const u8).add(OFFSET_ASTRO_ROOT_BODY) as *const Vec<'a, JSXChild<'a>>)
18626+ }
18627+ }
18628+ }
18629+
18630+ impl<'a, 't> GetAddress for AstroRootWithoutFrontmatter<'a, 't> {
18631+ #[inline]
18632+ fn address(&self) -> Address {
18633+ unsafe { Address::from_ptr(self.0) }
18634+ }
18635+ }
18636+
18637+ #[repr(transparent)]
18638+ #[derive(Clone, Copy, Debug)]
18639+ pub struct AstroRootWithoutBody<'a, 't>(
18640+ pub(crate) *const AstroRoot<'a>,
18641+ pub(crate) PhantomData<&'t ()>,
18642+ );
18643+
18644+ impl<'a, 't> AstroRootWithoutBody<'a, 't> {
18645+ #[inline]
18646+ pub fn span(self) -> &'t Span {
18647+ unsafe { &*((self.0 as *const u8).add(OFFSET_ASTRO_ROOT_SPAN) as *const Span) }
18648+ }
18649+
18650+ #[inline]
18651+ pub fn frontmatter(self) -> &'t Option<Box<'a, AstroFrontmatter<'a>>> {
18652+ unsafe {
18653+ &*((self.0 as *const u8).add(OFFSET_ASTRO_ROOT_FRONTMATTER)
18654+ as *const Option<Box<'a, AstroFrontmatter<'a>>>)
18655+ }
18656+ }
18657+ }
18658+
18659+ impl<'a, 't> GetAddress for AstroRootWithoutBody<'a, 't> {
18660+ #[inline]
18661+ fn address(&self) -> Address {
18662+ unsafe { Address::from_ptr(self.0) }
18663+ }
18664+ }
18665+
18666+ pub(crate) const OFFSET_ASTRO_FRONTMATTER_SPAN: usize = offset_of!(AstroFrontmatter, span);
18667+ pub(crate) const OFFSET_ASTRO_FRONTMATTER_PROGRAM: usize = offset_of!(AstroFrontmatter, program);
18668+
18669+ #[repr(transparent)]
18670+ #[derive(Clone, Copy, Debug)]
18671+ pub struct AstroFrontmatterWithoutProgram<'a, 't>(
18672+ pub(crate) *const AstroFrontmatter<'a>,
18673+ pub(crate) PhantomData<&'t ()>,
18674+ );
18675+
18676+ impl<'a, 't> AstroFrontmatterWithoutProgram<'a, 't> {
18677+ #[inline]
18678+ pub fn span(self) -> &'t Span {
18679+ unsafe { &*((self.0 as *const u8).add(OFFSET_ASTRO_FRONTMATTER_SPAN) as *const Span) }
18680+ }
18681+ }
18682+
18683+ impl<'a, 't> GetAddress for AstroFrontmatterWithoutProgram<'a, 't> {
18684+ #[inline]
18685+ fn address(&self) -> Address {
18686+ unsafe { Address::from_ptr(self.0) }
18687+ }
18688+ }
18689+
18690+ pub(crate) const OFFSET_ASTRO_SCRIPT_SPAN: usize = offset_of!(AstroScript, span);
18691+ pub(crate) const OFFSET_ASTRO_SCRIPT_PROGRAM: usize = offset_of!(AstroScript, program);
18692+
18693+ #[repr(transparent)]
18694+ #[derive(Clone, Copy, Debug)]
18695+ pub struct AstroScriptWithoutProgram<'a, 't>(
18696+ pub(crate) *const AstroScript<'a>,
18697+ pub(crate) PhantomData<&'t ()>,
18698+ );
18699+
18700+ impl<'a, 't> AstroScriptWithoutProgram<'a, 't> {
18701+ #[inline]
18702+ pub fn span(self) -> &'t Span {
18703+ unsafe { &*((self.0 as *const u8).add(OFFSET_ASTRO_SCRIPT_SPAN) as *const Span) }
18704+ }
18705+ }
18706+
18707+ impl<'a, 't> GetAddress for AstroScriptWithoutProgram<'a, 't> {
18708+ #[inline]
18709+ fn address(&self) -> Address {
18710+ unsafe { Address::from_ptr(self.0) }
18711+ }
18712+ }
0 commit comments