Re-enable AstNode.

This commit is contained in:
Tom Alexander 2023-10-29 21:33:43 -04:00
parent 1f3b5262b8
commit afe62de2b6
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
2 changed files with 205 additions and 205 deletions

View File

@ -52,6 +52,7 @@ use super::ITimestamp;
use super::IUnderline; use super::IUnderline;
use super::IVerbatim; use super::IVerbatim;
use super::IVerseBlock; use super::IVerseBlock;
use super::RefRegistry;
use crate::error::CustomError; use crate::error::CustomError;
use futures::future::{BoxFuture, FutureExt}; use futures::future::{BoxFuture, FutureExt};
@ -112,207 +113,207 @@ pub(crate) enum IAstNode {
Timestamp(ITimestamp), Timestamp(ITimestamp),
} }
// pub(crate) trait IntoIAstNode<'parse> { pub(crate) trait IntoIAstNode<'parse> {
// fn into_ast_node<'reg, 'orig, 'inp: 'reg + 'orig + 'parse>( fn into_ast_node<'orig>(
// &'orig self, &'orig self,
// registry: &'reg mut Registry<'orig, 'parse>, registry: RefRegistry<'orig, 'parse>,
// ) -> BoxFuture<'inp, Result<IAstNode, CustomError>>; ) -> BoxFuture<'orig, Result<IAstNode, CustomError>>;
// } }
// impl<'parse> IntoIAstNode<'parse> for organic::types::DocumentElement<'parse> { impl<'parse> IntoIAstNode<'parse> for organic::types::DocumentElement<'parse> {
// fn into_ast_node<'reg, 'orig, 'inp: 'reg + 'orig + 'parse>( fn into_ast_node<'orig>(
// &'orig self, &'orig self,
// registry: &'reg mut Registry<'orig, 'parse>, registry: RefRegistry<'orig, 'parse>,
// ) -> BoxFuture<'inp, Result<IAstNode, CustomError>> { ) -> BoxFuture<'orig, Result<IAstNode, CustomError>> {
// async move { async move {
// match self { match self {
// organic::types::DocumentElement::Heading(inner) => { organic::types::DocumentElement::Heading(inner) => {
// Ok(IAstNode::Heading(IHeading::new(registry, inner).await?)) Ok(IAstNode::Heading(IHeading::new(registry, inner).await?))
// } }
// organic::types::DocumentElement::Section(inner) => { organic::types::DocumentElement::Section(inner) => {
// Ok(IAstNode::Section(ISection::new(registry, inner).await?)) Ok(IAstNode::Section(ISection::new(registry, inner).await?))
// } }
// } }
// } }
// .boxed() .boxed()
// } }
// } }
// impl<'parse> IntoIAstNode<'parse> for organic::types::Element<'parse> { impl<'parse> IntoIAstNode<'parse> for organic::types::Element<'parse> {
// fn into_ast_node<'reg, 'orig, 'inp: 'reg + 'orig + 'parse>( fn into_ast_node<'orig>(
// &'orig self, &'orig self,
// registry: &'reg mut Registry<'orig, 'parse>, registry: RefRegistry<'orig, 'parse>,
// ) -> BoxFuture<'inp, Result<IAstNode, CustomError>> { ) -> BoxFuture<'orig, Result<IAstNode, CustomError>> {
// async move { async move {
// match self { match self {
// organic::types::Element::Paragraph(inner) => { organic::types::Element::Paragraph(inner) => {
// Ok(IAstNode::Paragraph(IParagraph::new(registry, inner).await?)) Ok(IAstNode::Paragraph(IParagraph::new(registry, inner).await?))
// } }
// organic::types::Element::PlainList(inner) => { organic::types::Element::PlainList(inner) => {
// Ok(IAstNode::PlainList(IPlainList::new(registry, inner).await?)) Ok(IAstNode::PlainList(IPlainList::new(registry, inner).await?))
// } }
// organic::types::Element::CenterBlock(inner) => Ok(IAstNode::CenterBlock( organic::types::Element::CenterBlock(inner) => Ok(IAstNode::CenterBlock(
// ICenterBlock::new(registry, inner).await?, ICenterBlock::new(registry, inner).await?,
// )), )),
// organic::types::Element::QuoteBlock(inner) => Ok(IAstNode::QuoteBlock( organic::types::Element::QuoteBlock(inner) => Ok(IAstNode::QuoteBlock(
// IQuoteBlock::new(registry, inner).await?, IQuoteBlock::new(registry, inner).await?,
// )), )),
// organic::types::Element::SpecialBlock(inner) => Ok(IAstNode::SpecialBlock( organic::types::Element::SpecialBlock(inner) => Ok(IAstNode::SpecialBlock(
// ISpecialBlock::new(registry, inner).await?, ISpecialBlock::new(registry, inner).await?,
// )), )),
// organic::types::Element::DynamicBlock(inner) => Ok(IAstNode::DynamicBlock( organic::types::Element::DynamicBlock(inner) => Ok(IAstNode::DynamicBlock(
// IDynamicBlock::new(registry, inner).await?, IDynamicBlock::new(registry, inner).await?,
// )), )),
// organic::types::Element::FootnoteDefinition(inner) => Ok( organic::types::Element::FootnoteDefinition(inner) => Ok(
// IAstNode::FootnoteDefinition(IFootnoteDefinition::new(registry, inner).await?), IAstNode::FootnoteDefinition(IFootnoteDefinition::new(registry, inner).await?),
// ), ),
// organic::types::Element::Comment(inner) => { organic::types::Element::Comment(inner) => {
// Ok(IAstNode::Comment(IComment::new(registry, inner).await?)) Ok(IAstNode::Comment(IComment::new(registry, inner).await?))
// } }
// organic::types::Element::Drawer(inner) => { organic::types::Element::Drawer(inner) => {
// Ok(IAstNode::Drawer(IDrawer::new(registry, inner).await?)) Ok(IAstNode::Drawer(IDrawer::new(registry, inner).await?))
// } }
// organic::types::Element::PropertyDrawer(inner) => Ok(IAstNode::PropertyDrawer( organic::types::Element::PropertyDrawer(inner) => Ok(IAstNode::PropertyDrawer(
// IPropertyDrawer::new(registry, inner).await?, IPropertyDrawer::new(registry, inner).await?,
// )), )),
// organic::types::Element::Table(inner) => { organic::types::Element::Table(inner) => {
// Ok(IAstNode::Table(ITable::new(registry, inner).await?)) Ok(IAstNode::Table(ITable::new(registry, inner).await?))
// } }
// organic::types::Element::VerseBlock(inner) => Ok(IAstNode::VerseBlock( organic::types::Element::VerseBlock(inner) => Ok(IAstNode::VerseBlock(
// IVerseBlock::new(registry, inner).await?, IVerseBlock::new(registry, inner).await?,
// )), )),
// organic::types::Element::CommentBlock(inner) => Ok(IAstNode::CommentBlock( organic::types::Element::CommentBlock(inner) => Ok(IAstNode::CommentBlock(
// ICommentBlock::new(registry, inner).await?, ICommentBlock::new(registry, inner).await?,
// )), )),
// organic::types::Element::ExampleBlock(inner) => Ok(IAstNode::ExampleBlock( organic::types::Element::ExampleBlock(inner) => Ok(IAstNode::ExampleBlock(
// IExampleBlock::new(registry, inner).await?, IExampleBlock::new(registry, inner).await?,
// )), )),
// organic::types::Element::ExportBlock(inner) => Ok(IAstNode::ExportBlock( organic::types::Element::ExportBlock(inner) => Ok(IAstNode::ExportBlock(
// IExportBlock::new(registry, inner).await?, IExportBlock::new(registry, inner).await?,
// )), )),
// organic::types::Element::SrcBlock(inner) => { organic::types::Element::SrcBlock(inner) => {
// Ok(IAstNode::SrcBlock(ISrcBlock::new(registry, inner).await?)) Ok(IAstNode::SrcBlock(ISrcBlock::new(registry, inner).await?))
// } }
// organic::types::Element::Clock(inner) => { organic::types::Element::Clock(inner) => {
// Ok(IAstNode::Clock(IClock::new(registry, inner).await?)) Ok(IAstNode::Clock(IClock::new(registry, inner).await?))
// } }
// organic::types::Element::DiarySexp(inner) => { organic::types::Element::DiarySexp(inner) => {
// Ok(IAstNode::DiarySexp(IDiarySexp::new(registry, inner).await?)) Ok(IAstNode::DiarySexp(IDiarySexp::new(registry, inner).await?))
// } }
// organic::types::Element::Planning(inner) => { organic::types::Element::Planning(inner) => {
// Ok(IAstNode::Planning(IPlanning::new(registry, inner).await?)) Ok(IAstNode::Planning(IPlanning::new(registry, inner).await?))
// } }
// organic::types::Element::FixedWidthArea(inner) => Ok(IAstNode::FixedWidthArea( organic::types::Element::FixedWidthArea(inner) => Ok(IAstNode::FixedWidthArea(
// IFixedWidthArea::new(registry, inner).await?, IFixedWidthArea::new(registry, inner).await?,
// )), )),
// organic::types::Element::HorizontalRule(inner) => Ok(IAstNode::HorizontalRule( organic::types::Element::HorizontalRule(inner) => Ok(IAstNode::HorizontalRule(
// IHorizontalRule::new(registry, inner).await?, IHorizontalRule::new(registry, inner).await?,
// )), )),
// organic::types::Element::Keyword(inner) => { organic::types::Element::Keyword(inner) => {
// Ok(IAstNode::Keyword(IKeyword::new(registry, inner).await?)) Ok(IAstNode::Keyword(IKeyword::new(registry, inner).await?))
// } }
// organic::types::Element::BabelCall(inner) => { organic::types::Element::BabelCall(inner) => {
// Ok(IAstNode::BabelCall(IBabelCall::new(registry, inner).await?)) Ok(IAstNode::BabelCall(IBabelCall::new(registry, inner).await?))
// } }
// organic::types::Element::LatexEnvironment(inner) => Ok(IAstNode::LatexEnvironment( organic::types::Element::LatexEnvironment(inner) => Ok(IAstNode::LatexEnvironment(
// ILatexEnvironment::new(registry, inner).await?, ILatexEnvironment::new(registry, inner).await?,
// )), )),
// } }
// } }
// .boxed() .boxed()
// } }
// } }
// impl<'parse> IntoIAstNode<'parse> for organic::types::Object<'parse> { impl<'parse> IntoIAstNode<'parse> for organic::types::Object<'parse> {
// fn into_ast_node<'reg, 'orig, 'inp: 'reg + 'orig + 'parse>( fn into_ast_node<'orig>(
// &'orig self, &'orig self,
// registry: &'reg mut Registry<'orig, 'parse>, registry: RefRegistry<'orig, 'parse>,
// ) -> BoxFuture<'inp, Result<IAstNode, CustomError>> { ) -> BoxFuture<'orig, Result<IAstNode, CustomError>> {
// async move { async move {
// match self { match self {
// organic::types::Object::Bold(inner) => { organic::types::Object::Bold(inner) => {
// Ok(IAstNode::Bold(IBold::new(registry, inner).await?)) Ok(IAstNode::Bold(IBold::new(registry, inner).await?))
// } }
// organic::types::Object::Italic(inner) => { organic::types::Object::Italic(inner) => {
// Ok(IAstNode::Italic(IItalic::new(registry, inner).await?)) Ok(IAstNode::Italic(IItalic::new(registry, inner).await?))
// } }
// organic::types::Object::Underline(inner) => { organic::types::Object::Underline(inner) => {
// Ok(IAstNode::Underline(IUnderline::new(registry, inner).await?)) Ok(IAstNode::Underline(IUnderline::new(registry, inner).await?))
// } }
// organic::types::Object::StrikeThrough(inner) => Ok(IAstNode::StrikeThrough( organic::types::Object::StrikeThrough(inner) => Ok(IAstNode::StrikeThrough(
// IStrikeThrough::new(registry, inner).await?, IStrikeThrough::new(registry, inner).await?,
// )), )),
// organic::types::Object::Code(inner) => { organic::types::Object::Code(inner) => {
// Ok(IAstNode::Code(ICode::new(registry, inner).await?)) Ok(IAstNode::Code(ICode::new(registry, inner).await?))
// } }
// organic::types::Object::Verbatim(inner) => { organic::types::Object::Verbatim(inner) => {
// Ok(IAstNode::Verbatim(IVerbatim::new(registry, inner).await?)) Ok(IAstNode::Verbatim(IVerbatim::new(registry, inner).await?))
// } }
// organic::types::Object::PlainText(inner) => { organic::types::Object::PlainText(inner) => {
// Ok(IAstNode::PlainText(IPlainText::new(registry, inner).await?)) Ok(IAstNode::PlainText(IPlainText::new(registry, inner).await?))
// } }
// organic::types::Object::RegularLink(inner) => Ok(IAstNode::RegularLink( organic::types::Object::RegularLink(inner) => Ok(IAstNode::RegularLink(
// IRegularLink::new(registry, inner).await?, IRegularLink::new(registry, inner).await?,
// )), )),
// organic::types::Object::RadioLink(inner) => { organic::types::Object::RadioLink(inner) => {
// Ok(IAstNode::RadioLink(IRadioLink::new(registry, inner).await?)) Ok(IAstNode::RadioLink(IRadioLink::new(registry, inner).await?))
// } }
// organic::types::Object::RadioTarget(inner) => Ok(IAstNode::RadioTarget( organic::types::Object::RadioTarget(inner) => Ok(IAstNode::RadioTarget(
// IRadioTarget::new(registry, inner).await?, IRadioTarget::new(registry, inner).await?,
// )), )),
// organic::types::Object::PlainLink(inner) => { organic::types::Object::PlainLink(inner) => {
// Ok(IAstNode::PlainLink(IPlainLink::new(registry, inner).await?)) Ok(IAstNode::PlainLink(IPlainLink::new(registry, inner).await?))
// } }
// organic::types::Object::AngleLink(inner) => { organic::types::Object::AngleLink(inner) => {
// Ok(IAstNode::AngleLink(IAngleLink::new(registry, inner).await?)) Ok(IAstNode::AngleLink(IAngleLink::new(registry, inner).await?))
// } }
// organic::types::Object::OrgMacro(inner) => { organic::types::Object::OrgMacro(inner) => {
// Ok(IAstNode::OrgMacro(IOrgMacro::new(registry, inner).await?)) Ok(IAstNode::OrgMacro(IOrgMacro::new(registry, inner).await?))
// } }
// organic::types::Object::Entity(inner) => { organic::types::Object::Entity(inner) => {
// Ok(IAstNode::Entity(IEntity::new(registry, inner).await?)) Ok(IAstNode::Entity(IEntity::new(registry, inner).await?))
// } }
// organic::types::Object::LatexFragment(inner) => Ok(IAstNode::LatexFragment( organic::types::Object::LatexFragment(inner) => Ok(IAstNode::LatexFragment(
// ILatexFragment::new(registry, inner).await?, ILatexFragment::new(registry, inner).await?,
// )), )),
// organic::types::Object::ExportSnippet(inner) => Ok(IAstNode::ExportSnippet( organic::types::Object::ExportSnippet(inner) => Ok(IAstNode::ExportSnippet(
// IExportSnippet::new(registry, inner).await?, IExportSnippet::new(registry, inner).await?,
// )), )),
// organic::types::Object::FootnoteReference(inner) => Ok( organic::types::Object::FootnoteReference(inner) => Ok(
// IAstNode::FootnoteReference(IFootnoteReference::new(registry, inner).await?), IAstNode::FootnoteReference(IFootnoteReference::new(registry, inner).await?),
// ), ),
// organic::types::Object::Citation(inner) => { organic::types::Object::Citation(inner) => {
// Ok(IAstNode::Citation(ICitation::new(registry, inner).await?)) Ok(IAstNode::Citation(ICitation::new(registry, inner).await?))
// } }
// organic::types::Object::CitationReference(inner) => Ok( organic::types::Object::CitationReference(inner) => Ok(
// IAstNode::CitationReference(ICitationReference::new(registry, inner).await?), IAstNode::CitationReference(ICitationReference::new(registry, inner).await?),
// ), ),
// organic::types::Object::InlineBabelCall(inner) => Ok(IAstNode::InlineBabelCall( organic::types::Object::InlineBabelCall(inner) => Ok(IAstNode::InlineBabelCall(
// IInlineBabelCall::new(registry, inner).await?, IInlineBabelCall::new(registry, inner).await?,
// )), )),
// organic::types::Object::InlineSourceBlock(inner) => Ok( organic::types::Object::InlineSourceBlock(inner) => Ok(
// IAstNode::InlineSourceBlock(IInlineSourceBlock::new(registry, inner).await?), IAstNode::InlineSourceBlock(IInlineSourceBlock::new(registry, inner).await?),
// ), ),
// organic::types::Object::LineBreak(inner) => { organic::types::Object::LineBreak(inner) => {
// Ok(IAstNode::LineBreak(ILineBreak::new(registry, inner).await?)) Ok(IAstNode::LineBreak(ILineBreak::new(registry, inner).await?))
// } }
// organic::types::Object::Target(inner) => { organic::types::Object::Target(inner) => {
// Ok(IAstNode::Target(ITarget::new(registry, inner).await?)) Ok(IAstNode::Target(ITarget::new(registry, inner).await?))
// } }
// organic::types::Object::StatisticsCookie(inner) => Ok(IAstNode::StatisticsCookie( organic::types::Object::StatisticsCookie(inner) => Ok(IAstNode::StatisticsCookie(
// IStatisticsCookie::new(registry, inner).await?, IStatisticsCookie::new(registry, inner).await?,
// )), )),
// organic::types::Object::Subscript(inner) => { organic::types::Object::Subscript(inner) => {
// Ok(IAstNode::Subscript(ISubscript::new(registry, inner).await?)) Ok(IAstNode::Subscript(ISubscript::new(registry, inner).await?))
// } }
// organic::types::Object::Superscript(inner) => Ok(IAstNode::Superscript( organic::types::Object::Superscript(inner) => Ok(IAstNode::Superscript(
// ISuperscript::new(registry, inner).await?, ISuperscript::new(registry, inner).await?,
// )), )),
// organic::types::Object::Timestamp(inner) => { organic::types::Object::Timestamp(inner) => {
// Ok(IAstNode::Timestamp(ITimestamp::new(registry, inner).await?)) Ok(IAstNode::Timestamp(ITimestamp::new(registry, inner).await?))
// } }
// } }
// } }
// .boxed() .boxed()
// } }
// } }

View File

@ -9,6 +9,7 @@ use organic::types::Element;
use organic::types::Object; use organic::types::Object;
use super::ast_node::IAstNode; use super::ast_node::IAstNode;
use super::ast_node::IntoIAstNode;
use super::RefRegistry; use super::RefRegistry;
type IdCounter = u16; type IdCounter = u16;
@ -117,8 +118,7 @@ async fn convert_reference_contents<'orig, 'parse>(
let contents = { let contents = {
let mut ret = Vec::new(); let mut ret = Vec::new();
for obj in contents.iter() { for obj in contents.iter() {
// TODO ret.push(obj.into_ast_node(registry.clone()).await?);
// ret.push(obj.into_ast_node(registry).await?);
} }
ret ret
}; };
@ -133,8 +133,7 @@ async fn convert_definition_contents<'orig, 'parse>(
let contents = { let contents = {
let mut ret = Vec::new(); let mut ret = Vec::new();
for obj in contents.iter() { for obj in contents.iter() {
// TODO ret.push(obj.into_ast_node(registry.clone()).await?);
// ret.push(obj.into_ast_node(registry).await?);
} }
ret ret
}; };