2023-09-27 15:38:33 -04:00
use std ::marker ::PhantomData ;
2023-09-27 15:07:26 -04:00
use super ::ast_node ::AstNode ;
2023-09-27 15:47:01 -04:00
use super ::macros ::children_iter ;
use super ::macros ::empty_iter ;
2023-09-27 18:27:52 -04:00
use super ::macros ::multi_field_iter ;
2023-09-27 19:02:33 -04:00
use crate ::types ::AngleLink ;
2023-09-27 18:55:50 -04:00
use crate ::types ::BabelCall ;
2023-09-27 15:17:56 -04:00
use crate ::types ::Bold ;
2023-09-27 19:02:33 -04:00
use crate ::types ::Citation ;
use crate ::types ::CitationReference ;
2023-09-27 18:55:50 -04:00
use crate ::types ::Clock ;
2023-09-27 15:38:33 -04:00
use crate ::types ::Code ;
2023-09-27 18:55:50 -04:00
use crate ::types ::Comment ;
use crate ::types ::CommentBlock ;
use crate ::types ::DiarySexp ;
2023-09-27 18:05:53 -04:00
use crate ::types ::Document ;
2023-09-27 18:00:30 -04:00
use crate ::types ::DocumentElement ;
2023-09-27 18:55:50 -04:00
use crate ::types ::Drawer ;
use crate ::types ::DynamicBlock ;
2023-09-27 18:00:30 -04:00
use crate ::types ::Element ;
2023-09-27 19:02:33 -04:00
use crate ::types ::Entity ;
2023-09-27 18:55:50 -04:00
use crate ::types ::ExampleBlock ;
use crate ::types ::ExportBlock ;
2023-09-27 19:02:33 -04:00
use crate ::types ::ExportSnippet ;
2023-09-27 18:55:50 -04:00
use crate ::types ::FixedWidthArea ;
use crate ::types ::FootnoteDefinition ;
2023-09-27 19:02:33 -04:00
use crate ::types ::FootnoteReference ;
2023-09-27 18:55:50 -04:00
use crate ::types ::GreaterBlock ;
2023-09-27 15:56:45 -04:00
use crate ::types ::Heading ;
2023-09-27 18:55:50 -04:00
use crate ::types ::HorizontalRule ;
2023-09-27 19:02:33 -04:00
use crate ::types ::InlineBabelCall ;
use crate ::types ::InlineSourceBlock ;
2023-09-27 15:28:43 -04:00
use crate ::types ::Italic ;
2023-09-27 18:55:50 -04:00
use crate ::types ::Keyword ;
use crate ::types ::LatexEnvironment ;
2023-09-27 19:02:33 -04:00
use crate ::types ::LatexFragment ;
use crate ::types ::LineBreak ;
2023-09-27 18:55:50 -04:00
use crate ::types ::NodeProperty ;
2023-09-27 13:48:17 -04:00
use crate ::types ::Object ;
2023-09-27 19:02:33 -04:00
use crate ::types ::OrgMacro ;
2023-09-27 18:21:42 -04:00
use crate ::types ::Paragraph ;
2023-09-27 19:02:33 -04:00
use crate ::types ::PlainLink ;
2023-09-27 18:21:42 -04:00
use crate ::types ::PlainList ;
use crate ::types ::PlainListItem ;
2023-09-27 15:56:45 -04:00
use crate ::types ::PlainText ;
2023-09-27 18:55:50 -04:00
use crate ::types ::Planning ;
use crate ::types ::PropertyDrawer ;
2023-09-27 15:56:45 -04:00
use crate ::types ::RadioLink ;
2023-09-27 19:02:33 -04:00
use crate ::types ::RadioTarget ;
2023-09-27 15:56:45 -04:00
use crate ::types ::RegularLink ;
2023-09-27 18:05:53 -04:00
use crate ::types ::Section ;
2023-09-27 18:55:50 -04:00
use crate ::types ::SrcBlock ;
2023-09-27 19:02:33 -04:00
use crate ::types ::StatisticsCookie ;
2023-09-27 15:38:33 -04:00
use crate ::types ::StrikeThrough ;
2023-09-27 19:02:33 -04:00
use crate ::types ::Subscript ;
use crate ::types ::Superscript ;
2023-09-27 18:55:50 -04:00
use crate ::types ::Table ;
use crate ::types ::TableCell ;
use crate ::types ::TableRow ;
2023-09-27 19:02:33 -04:00
use crate ::types ::Target ;
use crate ::types ::Timestamp ;
2023-09-27 15:38:33 -04:00
use crate ::types ::Underline ;
2023-09-27 15:47:01 -04:00
use crate ::types ::Verbatim ;
2023-09-27 18:55:50 -04:00
use crate ::types ::VerseBlock ;
2023-09-27 13:48:17 -04:00
2023-09-27 15:47:01 -04:00
/// Iterator over the AST nodes contained within the starting node.
///
/// This only iterates over the children, not the starting node itself. So an AstNodeIter::PlainList would only return PlainListItems, not the PlainList.
///
/// This only iterates over AST nodes, so an AstNodeIter::Heading would iterate over both the title and section contents, but it would not iterate over simple strings like the TODO keyword or priority.
2023-09-27 15:07:26 -04:00
pub enum AstNodeIter < ' r , ' s > {
2023-09-27 14:24:08 -04:00
// Document Nodes
2023-09-27 18:05:53 -04:00
Document ( DocumentIter < ' r , ' s > ) ,
2023-09-27 15:56:45 -04:00
Heading ( HeadingIter < ' r , ' s > ) ,
2023-09-27 18:05:53 -04:00
Section ( SectionIter < ' r , ' s > ) ,
2023-09-27 14:24:08 -04:00
// Elements
2023-09-27 18:21:42 -04:00
Paragraph ( ParagraphIter < ' r , ' s > ) ,
PlainList ( PlainListIter < ' r , ' s > ) ,
2023-09-27 18:27:52 -04:00
PlainListItem ( PlainListItemIter < ' r , ' s > ) ,
2023-09-27 18:55:50 -04:00
GreaterBlock ( GreaterBlockIter < ' r , ' s > ) ,
DynamicBlock ( DynamicBlockIter < ' r , ' s > ) ,
FootnoteDefinition ( FootnoteDefinitionIter < ' r , ' s > ) ,
Comment ( CommentIter < ' r , ' s > ) ,
Drawer ( DrawerIter < ' r , ' s > ) ,
PropertyDrawer ( PropertyDrawerIter < ' r , ' s > ) ,
NodeProperty ( NodePropertyIter < ' r , ' s > ) ,
Table ( TableIter < ' r , ' s > ) ,
TableRow ( TableRowIter < ' r , ' s > ) ,
VerseBlock ( VerseBlockIter < ' r , ' s > ) ,
CommentBlock ( CommentBlockIter < ' r , ' s > ) ,
ExampleBlock ( ExampleBlockIter < ' r , ' s > ) ,
ExportBlock ( ExportBlockIter < ' r , ' s > ) ,
SrcBlock ( SrcBlockIter < ' r , ' s > ) ,
Clock ( ClockIter < ' r , ' s > ) ,
DiarySexp ( DiarySexpIter < ' r , ' s > ) ,
Planning ( PlanningIter < ' r , ' s > ) ,
FixedWidthArea ( FixedWidthAreaIter < ' r , ' s > ) ,
HorizontalRule ( HorizontalRuleIter < ' r , ' s > ) ,
Keyword ( KeywordIter < ' r , ' s > ) ,
BabelCall ( BabelCallIter < ' r , ' s > ) ,
LatexEnvironment ( LatexEnvironmentIter < ' r , ' s > ) ,
2023-09-27 14:24:08 -04:00
// Objects
2023-09-27 15:07:26 -04:00
Bold ( BoldIter < ' r , ' s > ) ,
2023-09-27 15:28:43 -04:00
Italic ( ItalicIter < ' r , ' s > ) ,
2023-09-27 15:38:33 -04:00
Underline ( UnderlineIter < ' r , ' s > ) ,
StrikeThrough ( StrikeThroughIter < ' r , ' s > ) ,
Code ( CodeIter < ' r , ' s > ) ,
2023-09-27 15:47:01 -04:00
Verbatim ( VerbatimIter < ' r , ' s > ) ,
2023-09-27 15:56:45 -04:00
PlainText ( PlainTextIter < ' r , ' s > ) ,
RegularLink ( RegularLinkIter < ' r , ' s > ) ,
RadioLink ( RadioLinkIter < ' r , ' s > ) ,
2023-09-27 19:02:33 -04:00
RadioTarget ( RadioTargetIter < ' r , ' s > ) ,
PlainLink ( PlainLinkIter < ' r , ' s > ) ,
AngleLink ( AngleLinkIter < ' r , ' s > ) ,
OrgMacro ( OrgMacroIter < ' r , ' s > ) ,
Entity ( EntityIter < ' r , ' s > ) ,
LatexFragment ( LatexFragmentIter < ' r , ' s > ) ,
ExportSnippet ( ExportSnippetIter < ' r , ' s > ) ,
FootnoteReference ( FootnoteReferenceIter < ' r , ' s > ) ,
Citation ( CitationIter < ' r , ' s > ) ,
CitationReference ( CitationReferenceIter < ' r , ' s > ) ,
InlineBabelCall ( InlineBabelCallIter < ' r , ' s > ) ,
InlineSourceBlock ( InlineSourceBlockIter < ' r , ' s > ) ,
LineBreak ( LineBreakIter < ' r , ' s > ) ,
Target ( TargetIter < ' r , ' s > ) ,
StatisticsCookie ( StatisticsCookieIter < ' r , ' s > ) ,
Subscript ( SubscriptIter < ' r , ' s > ) ,
Superscript ( SuperscriptIter < ' r , ' s > ) ,
2023-09-27 18:55:50 -04:00
TableCell ( TableCellIter < ' r , ' s > ) ,
2023-09-27 19:02:33 -04:00
Timestamp ( TimestampIter < ' r , ' s > ) ,
2023-09-27 14:24:08 -04:00
}
2023-09-27 18:38:51 -04:00
multi_field_iter! (
Document < ' s > ,
DocumentIter ,
zeroth_section ,
std ::option ::Iter < ' r , Section < ' s > > ,
children ,
std ::slice ::Iter < ' r , Heading < ' s > >
) ;
multi_field_iter! (
Heading < ' s > ,
HeadingIter ,
title ,
std ::slice ::Iter < ' r , Object < ' s > > ,
children ,
std ::slice ::Iter < ' r , DocumentElement < ' s > >
) ;
2023-09-27 18:05:53 -04:00
children_iter! ( Section < ' s > , SectionIter , std ::slice ::Iter < ' r , Element < ' s > > ) ;
2023-09-27 18:21:42 -04:00
children_iter! (
Paragraph < ' s > ,
ParagraphIter ,
std ::slice ::Iter < ' r , Object < ' s > >
) ;
children_iter! (
PlainList < ' s > ,
PlainListIter ,
std ::slice ::Iter < ' r , PlainListItem < ' s > >
) ;
2023-09-27 18:27:52 -04:00
multi_field_iter! (
PlainListItem < ' s > ,
PlainListItemIter ,
tag ,
std ::slice ::Iter < ' r , Object < ' s > > ,
children ,
std ::slice ::Iter < ' r , Element < ' s > >
) ;
2023-09-27 18:55:50 -04:00
children_iter! (
GreaterBlock < ' s > ,
GreaterBlockIter ,
std ::slice ::Iter < ' r , Element < ' s > >
) ;
children_iter! (
DynamicBlock < ' s > ,
DynamicBlockIter ,
std ::slice ::Iter < ' r , Element < ' s > >
) ;
children_iter! (
FootnoteDefinition < ' s > ,
FootnoteDefinitionIter ,
std ::slice ::Iter < ' r , Element < ' s > >
) ;
empty_iter! ( Comment < ' s > , CommentIter ) ;
children_iter! ( Drawer < ' s > , DrawerIter , std ::slice ::Iter < ' r , Element < ' s > > ) ;
children_iter! (
PropertyDrawer < ' s > ,
PropertyDrawerIter ,
std ::slice ::Iter < ' r , NodeProperty < ' s > >
) ;
empty_iter! ( NodeProperty < ' s > , NodePropertyIter ) ;
children_iter! ( Table < ' s > , TableIter , std ::slice ::Iter < ' r , TableRow < ' s > > ) ;
children_iter! (
TableRow < ' s > ,
TableRowIter ,
std ::slice ::Iter < ' r , TableCell < ' s > >
) ;
children_iter! (
VerseBlock < ' s > ,
VerseBlockIter ,
std ::slice ::Iter < ' r , Object < ' s > >
) ;
empty_iter! ( CommentBlock < ' s > , CommentBlockIter ) ;
empty_iter! ( ExampleBlock < ' s > , ExampleBlockIter ) ;
empty_iter! ( ExportBlock < ' s > , ExportBlockIter ) ;
empty_iter! ( SrcBlock < ' s > , SrcBlockIter ) ;
empty_iter! ( Clock < ' s > , ClockIter ) ;
empty_iter! ( DiarySexp < ' s > , DiarySexpIter ) ;
empty_iter! ( Planning < ' s > , PlanningIter ) ;
empty_iter! ( FixedWidthArea < ' s > , FixedWidthAreaIter ) ;
empty_iter! ( HorizontalRule < ' s > , HorizontalRuleIter ) ;
empty_iter! ( Keyword < ' s > , KeywordIter ) ;
empty_iter! ( BabelCall < ' s > , BabelCallIter ) ;
empty_iter! ( LatexEnvironment < ' s > , LatexEnvironmentIter ) ;
2023-09-27 15:56:45 -04:00
children_iter! ( Bold < ' s > , BoldIter , std ::slice ::Iter < ' r , Object < ' s > > ) ;
2023-09-27 15:47:01 -04:00
children_iter! ( Italic < ' s > , ItalicIter , std ::slice ::Iter < ' r , Object < ' s > > ) ;
children_iter! (
2023-09-27 15:38:33 -04:00
Underline < ' s > ,
UnderlineIter ,
std ::slice ::Iter < ' r , Object < ' s > >
) ;
2023-09-27 15:47:01 -04:00
children_iter! (
2023-09-27 15:38:33 -04:00
StrikeThrough < ' s > ,
StrikeThroughIter ,
std ::slice ::Iter < ' r , Object < ' s > >
) ;
2023-09-27 15:56:45 -04:00
empty_iter! ( Code < ' s > , CodeIter ) ;
2023-09-27 15:47:01 -04:00
empty_iter! ( Verbatim < ' s > , VerbatimIter ) ;
2023-09-27 15:56:45 -04:00
empty_iter! ( PlainText < ' s > , PlainTextIter ) ;
empty_iter! ( RegularLink < ' s > , RegularLinkIter ) ;
children_iter! (
RadioLink < ' s > ,
RadioLinkIter ,
std ::slice ::Iter < ' r , Object < ' s > >
) ;
2023-09-27 19:02:33 -04:00
children_iter! (
RadioTarget < ' s > ,
RadioTargetIter ,
std ::slice ::Iter < ' r , Object < ' s > >
) ;
empty_iter! ( PlainLink < ' s > , PlainLinkIter ) ;
empty_iter! ( AngleLink < ' s > , AngleLinkIter ) ;
empty_iter! ( OrgMacro < ' s > , OrgMacroIter ) ;
empty_iter! ( Entity < ' s > , EntityIter ) ;
empty_iter! ( LatexFragment < ' s > , LatexFragmentIter ) ;
empty_iter! ( ExportSnippet < ' s > , ExportSnippetIter ) ;
multi_field_iter! (
FootnoteReference < ' s > ,
FootnoteReferenceIter ,
definition ,
std ::slice ::Iter < ' r , Object < ' s > > ,
) ;
empty_iter! ( Citation < ' s > , CitationIter ) ;
empty_iter! ( CitationReference < ' s > , CitationReferenceIter ) ;
empty_iter! ( InlineBabelCall < ' s > , InlineBabelCallIter ) ;
empty_iter! ( InlineSourceBlock < ' s > , InlineSourceBlockIter ) ;
empty_iter! ( LineBreak < ' s > , LineBreakIter ) ;
empty_iter! ( Target < ' s > , TargetIter ) ;
empty_iter! ( StatisticsCookie < ' s > , StatisticsCookieIter ) ;
empty_iter! ( Subscript < ' s > , SubscriptIter ) ;
empty_iter! ( Superscript < ' s > , SuperscriptIter ) ;
2023-09-27 18:55:50 -04:00
children_iter! (
TableCell < ' s > ,
TableCellIter ,
std ::slice ::Iter < ' r , Object < ' s > >
) ;
2023-09-27 19:02:33 -04:00
empty_iter! ( Timestamp < ' s > , TimestampIter ) ;