Wrap the intermediate Registry in an IntermediateContext.
This is currently just to maintain consistency with the render phase's RenderContext but in the future it should allow us to include immutable data that is not locked behind the ArcMutex.
This commit is contained in:
@@ -18,7 +18,6 @@ use super::plain_link::IPlainLink;
|
||||
use super::plain_text::IPlainText;
|
||||
use super::radio_link::IRadioLink;
|
||||
use super::radio_target::IRadioTarget;
|
||||
|
||||
use super::regular_link::IRegularLink;
|
||||
use super::statistics_cookie::IStatisticsCookie;
|
||||
use super::strike_through::IStrikeThrough;
|
||||
@@ -52,7 +51,7 @@ use super::ITimestamp;
|
||||
use super::IUnderline;
|
||||
use super::IVerbatim;
|
||||
use super::IVerseBlock;
|
||||
use super::RefRegistry;
|
||||
use super::IntermediateContext;
|
||||
use crate::error::CustomError;
|
||||
use futures::future::{BoxFuture, FutureExt};
|
||||
|
||||
@@ -116,23 +115,23 @@ pub(crate) enum IAstNode {
|
||||
pub(crate) trait IntoIAstNode<'parse> {
|
||||
fn into_ast_node<'orig>(
|
||||
&'orig self,
|
||||
registry: RefRegistry<'orig, 'parse>,
|
||||
intermediate_context: IntermediateContext<'orig, 'parse>,
|
||||
) -> BoxFuture<'orig, Result<IAstNode, CustomError>>;
|
||||
}
|
||||
|
||||
impl<'parse> IntoIAstNode<'parse> for organic::types::DocumentElement<'parse> {
|
||||
fn into_ast_node<'orig>(
|
||||
&'orig self,
|
||||
registry: RefRegistry<'orig, 'parse>,
|
||||
intermediate_context: IntermediateContext<'orig, 'parse>,
|
||||
) -> BoxFuture<'orig, Result<IAstNode, CustomError>> {
|
||||
async move {
|
||||
match self {
|
||||
organic::types::DocumentElement::Heading(inner) => {
|
||||
Ok(IAstNode::Heading(IHeading::new(registry, inner).await?))
|
||||
}
|
||||
organic::types::DocumentElement::Section(inner) => {
|
||||
Ok(IAstNode::Section(ISection::new(registry, inner).await?))
|
||||
}
|
||||
organic::types::DocumentElement::Heading(inner) => Ok(IAstNode::Heading(
|
||||
IHeading::new(intermediate_context, inner).await?,
|
||||
)),
|
||||
organic::types::DocumentElement::Section(inner) => Ok(IAstNode::Section(
|
||||
ISection::new(intermediate_context, inner).await?,
|
||||
)),
|
||||
}
|
||||
}
|
||||
.boxed()
|
||||
@@ -142,81 +141,83 @@ impl<'parse> IntoIAstNode<'parse> for organic::types::DocumentElement<'parse> {
|
||||
impl<'parse> IntoIAstNode<'parse> for organic::types::Element<'parse> {
|
||||
fn into_ast_node<'orig>(
|
||||
&'orig self,
|
||||
registry: RefRegistry<'orig, 'parse>,
|
||||
intermediate_context: IntermediateContext<'orig, 'parse>,
|
||||
) -> BoxFuture<'orig, Result<IAstNode, CustomError>> {
|
||||
async move {
|
||||
match self {
|
||||
organic::types::Element::Paragraph(inner) => {
|
||||
Ok(IAstNode::Paragraph(IParagraph::new(registry, inner).await?))
|
||||
}
|
||||
organic::types::Element::PlainList(inner) => {
|
||||
Ok(IAstNode::PlainList(IPlainList::new(registry, inner).await?))
|
||||
}
|
||||
organic::types::Element::Paragraph(inner) => Ok(IAstNode::Paragraph(
|
||||
IParagraph::new(intermediate_context, inner).await?,
|
||||
)),
|
||||
organic::types::Element::PlainList(inner) => Ok(IAstNode::PlainList(
|
||||
IPlainList::new(intermediate_context, inner).await?,
|
||||
)),
|
||||
organic::types::Element::CenterBlock(inner) => Ok(IAstNode::CenterBlock(
|
||||
ICenterBlock::new(registry, inner).await?,
|
||||
ICenterBlock::new(intermediate_context, inner).await?,
|
||||
)),
|
||||
organic::types::Element::QuoteBlock(inner) => Ok(IAstNode::QuoteBlock(
|
||||
IQuoteBlock::new(registry, inner).await?,
|
||||
IQuoteBlock::new(intermediate_context, inner).await?,
|
||||
)),
|
||||
organic::types::Element::SpecialBlock(inner) => Ok(IAstNode::SpecialBlock(
|
||||
ISpecialBlock::new(registry, inner).await?,
|
||||
ISpecialBlock::new(intermediate_context, inner).await?,
|
||||
)),
|
||||
organic::types::Element::DynamicBlock(inner) => Ok(IAstNode::DynamicBlock(
|
||||
IDynamicBlock::new(registry, inner).await?,
|
||||
IDynamicBlock::new(intermediate_context, inner).await?,
|
||||
)),
|
||||
organic::types::Element::FootnoteDefinition(inner) => Ok(
|
||||
IAstNode::FootnoteDefinition(IFootnoteDefinition::new(registry, inner).await?),
|
||||
),
|
||||
organic::types::Element::Comment(inner) => {
|
||||
Ok(IAstNode::Comment(IComment::new(registry, inner).await?))
|
||||
}
|
||||
organic::types::Element::Drawer(inner) => {
|
||||
Ok(IAstNode::Drawer(IDrawer::new(registry, inner).await?))
|
||||
organic::types::Element::FootnoteDefinition(inner) => {
|
||||
Ok(IAstNode::FootnoteDefinition(
|
||||
IFootnoteDefinition::new(intermediate_context, inner).await?,
|
||||
))
|
||||
}
|
||||
organic::types::Element::Comment(inner) => Ok(IAstNode::Comment(
|
||||
IComment::new(intermediate_context, inner).await?,
|
||||
)),
|
||||
organic::types::Element::Drawer(inner) => Ok(IAstNode::Drawer(
|
||||
IDrawer::new(intermediate_context, inner).await?,
|
||||
)),
|
||||
organic::types::Element::PropertyDrawer(inner) => Ok(IAstNode::PropertyDrawer(
|
||||
IPropertyDrawer::new(registry, inner).await?,
|
||||
IPropertyDrawer::new(intermediate_context, inner).await?,
|
||||
)),
|
||||
organic::types::Element::Table(inner) => Ok(IAstNode::Table(
|
||||
ITable::new(intermediate_context, inner).await?,
|
||||
)),
|
||||
organic::types::Element::Table(inner) => {
|
||||
Ok(IAstNode::Table(ITable::new(registry, inner).await?))
|
||||
}
|
||||
organic::types::Element::VerseBlock(inner) => Ok(IAstNode::VerseBlock(
|
||||
IVerseBlock::new(registry, inner).await?,
|
||||
IVerseBlock::new(intermediate_context, inner).await?,
|
||||
)),
|
||||
organic::types::Element::CommentBlock(inner) => Ok(IAstNode::CommentBlock(
|
||||
ICommentBlock::new(registry, inner).await?,
|
||||
ICommentBlock::new(intermediate_context, inner).await?,
|
||||
)),
|
||||
organic::types::Element::ExampleBlock(inner) => Ok(IAstNode::ExampleBlock(
|
||||
IExampleBlock::new(registry, inner).await?,
|
||||
IExampleBlock::new(intermediate_context, inner).await?,
|
||||
)),
|
||||
organic::types::Element::ExportBlock(inner) => Ok(IAstNode::ExportBlock(
|
||||
IExportBlock::new(registry, inner).await?,
|
||||
IExportBlock::new(intermediate_context, inner).await?,
|
||||
)),
|
||||
organic::types::Element::SrcBlock(inner) => Ok(IAstNode::SrcBlock(
|
||||
ISrcBlock::new(intermediate_context, inner).await?,
|
||||
)),
|
||||
organic::types::Element::Clock(inner) => Ok(IAstNode::Clock(
|
||||
IClock::new(intermediate_context, inner).await?,
|
||||
)),
|
||||
organic::types::Element::DiarySexp(inner) => Ok(IAstNode::DiarySexp(
|
||||
IDiarySexp::new(intermediate_context, inner).await?,
|
||||
)),
|
||||
organic::types::Element::Planning(inner) => Ok(IAstNode::Planning(
|
||||
IPlanning::new(intermediate_context, inner).await?,
|
||||
)),
|
||||
organic::types::Element::SrcBlock(inner) => {
|
||||
Ok(IAstNode::SrcBlock(ISrcBlock::new(registry, inner).await?))
|
||||
}
|
||||
organic::types::Element::Clock(inner) => {
|
||||
Ok(IAstNode::Clock(IClock::new(registry, inner).await?))
|
||||
}
|
||||
organic::types::Element::DiarySexp(inner) => {
|
||||
Ok(IAstNode::DiarySexp(IDiarySexp::new(registry, inner).await?))
|
||||
}
|
||||
organic::types::Element::Planning(inner) => {
|
||||
Ok(IAstNode::Planning(IPlanning::new(registry, inner).await?))
|
||||
}
|
||||
organic::types::Element::FixedWidthArea(inner) => Ok(IAstNode::FixedWidthArea(
|
||||
IFixedWidthArea::new(registry, inner).await?,
|
||||
IFixedWidthArea::new(intermediate_context, inner).await?,
|
||||
)),
|
||||
organic::types::Element::HorizontalRule(inner) => Ok(IAstNode::HorizontalRule(
|
||||
IHorizontalRule::new(registry, inner).await?,
|
||||
IHorizontalRule::new(intermediate_context, inner).await?,
|
||||
)),
|
||||
organic::types::Element::Keyword(inner) => Ok(IAstNode::Keyword(
|
||||
IKeyword::new(intermediate_context, inner).await?,
|
||||
)),
|
||||
organic::types::Element::BabelCall(inner) => Ok(IAstNode::BabelCall(
|
||||
IBabelCall::new(intermediate_context, inner).await?,
|
||||
)),
|
||||
organic::types::Element::Keyword(inner) => {
|
||||
Ok(IAstNode::Keyword(IKeyword::new(registry, inner).await?))
|
||||
}
|
||||
organic::types::Element::BabelCall(inner) => {
|
||||
Ok(IAstNode::BabelCall(IBabelCall::new(registry, inner).await?))
|
||||
}
|
||||
organic::types::Element::LatexEnvironment(inner) => Ok(IAstNode::LatexEnvironment(
|
||||
ILatexEnvironment::new(registry, inner).await?,
|
||||
ILatexEnvironment::new(intermediate_context, inner).await?,
|
||||
)),
|
||||
}
|
||||
}
|
||||
@@ -227,91 +228,97 @@ impl<'parse> IntoIAstNode<'parse> for organic::types::Element<'parse> {
|
||||
impl<'parse> IntoIAstNode<'parse> for organic::types::Object<'parse> {
|
||||
fn into_ast_node<'orig>(
|
||||
&'orig self,
|
||||
registry: RefRegistry<'orig, 'parse>,
|
||||
intermediate_context: IntermediateContext<'orig, 'parse>,
|
||||
) -> BoxFuture<'orig, Result<IAstNode, CustomError>> {
|
||||
async move {
|
||||
match self {
|
||||
organic::types::Object::Bold(inner) => {
|
||||
Ok(IAstNode::Bold(IBold::new(registry, inner).await?))
|
||||
}
|
||||
organic::types::Object::Italic(inner) => {
|
||||
Ok(IAstNode::Italic(IItalic::new(registry, inner).await?))
|
||||
}
|
||||
organic::types::Object::Underline(inner) => {
|
||||
Ok(IAstNode::Underline(IUnderline::new(registry, inner).await?))
|
||||
}
|
||||
organic::types::Object::Bold(inner) => Ok(IAstNode::Bold(
|
||||
IBold::new(intermediate_context, inner).await?,
|
||||
)),
|
||||
organic::types::Object::Italic(inner) => Ok(IAstNode::Italic(
|
||||
IItalic::new(intermediate_context, inner).await?,
|
||||
)),
|
||||
organic::types::Object::Underline(inner) => Ok(IAstNode::Underline(
|
||||
IUnderline::new(intermediate_context, inner).await?,
|
||||
)),
|
||||
organic::types::Object::StrikeThrough(inner) => Ok(IAstNode::StrikeThrough(
|
||||
IStrikeThrough::new(registry, inner).await?,
|
||||
IStrikeThrough::new(intermediate_context, inner).await?,
|
||||
)),
|
||||
organic::types::Object::Code(inner) => Ok(IAstNode::Code(
|
||||
ICode::new(intermediate_context, inner).await?,
|
||||
)),
|
||||
organic::types::Object::Verbatim(inner) => Ok(IAstNode::Verbatim(
|
||||
IVerbatim::new(intermediate_context, inner).await?,
|
||||
)),
|
||||
organic::types::Object::PlainText(inner) => Ok(IAstNode::PlainText(
|
||||
IPlainText::new(intermediate_context, inner).await?,
|
||||
)),
|
||||
organic::types::Object::Code(inner) => {
|
||||
Ok(IAstNode::Code(ICode::new(registry, inner).await?))
|
||||
}
|
||||
organic::types::Object::Verbatim(inner) => {
|
||||
Ok(IAstNode::Verbatim(IVerbatim::new(registry, inner).await?))
|
||||
}
|
||||
organic::types::Object::PlainText(inner) => {
|
||||
Ok(IAstNode::PlainText(IPlainText::new(registry, inner).await?))
|
||||
}
|
||||
organic::types::Object::RegularLink(inner) => Ok(IAstNode::RegularLink(
|
||||
IRegularLink::new(registry, inner).await?,
|
||||
IRegularLink::new(intermediate_context, inner).await?,
|
||||
)),
|
||||
organic::types::Object::RadioLink(inner) => Ok(IAstNode::RadioLink(
|
||||
IRadioLink::new(intermediate_context, inner).await?,
|
||||
)),
|
||||
organic::types::Object::RadioLink(inner) => {
|
||||
Ok(IAstNode::RadioLink(IRadioLink::new(registry, inner).await?))
|
||||
}
|
||||
organic::types::Object::RadioTarget(inner) => Ok(IAstNode::RadioTarget(
|
||||
IRadioTarget::new(registry, inner).await?,
|
||||
IRadioTarget::new(intermediate_context, inner).await?,
|
||||
)),
|
||||
organic::types::Object::PlainLink(inner) => Ok(IAstNode::PlainLink(
|
||||
IPlainLink::new(intermediate_context, inner).await?,
|
||||
)),
|
||||
organic::types::Object::AngleLink(inner) => Ok(IAstNode::AngleLink(
|
||||
IAngleLink::new(intermediate_context, inner).await?,
|
||||
)),
|
||||
organic::types::Object::OrgMacro(inner) => Ok(IAstNode::OrgMacro(
|
||||
IOrgMacro::new(intermediate_context, inner).await?,
|
||||
)),
|
||||
organic::types::Object::Entity(inner) => Ok(IAstNode::Entity(
|
||||
IEntity::new(intermediate_context, inner).await?,
|
||||
)),
|
||||
organic::types::Object::PlainLink(inner) => {
|
||||
Ok(IAstNode::PlainLink(IPlainLink::new(registry, inner).await?))
|
||||
}
|
||||
organic::types::Object::AngleLink(inner) => {
|
||||
Ok(IAstNode::AngleLink(IAngleLink::new(registry, inner).await?))
|
||||
}
|
||||
organic::types::Object::OrgMacro(inner) => {
|
||||
Ok(IAstNode::OrgMacro(IOrgMacro::new(registry, inner).await?))
|
||||
}
|
||||
organic::types::Object::Entity(inner) => {
|
||||
Ok(IAstNode::Entity(IEntity::new(registry, inner).await?))
|
||||
}
|
||||
organic::types::Object::LatexFragment(inner) => Ok(IAstNode::LatexFragment(
|
||||
ILatexFragment::new(registry, inner).await?,
|
||||
ILatexFragment::new(intermediate_context, inner).await?,
|
||||
)),
|
||||
organic::types::Object::ExportSnippet(inner) => Ok(IAstNode::ExportSnippet(
|
||||
IExportSnippet::new(registry, inner).await?,
|
||||
IExportSnippet::new(intermediate_context, inner).await?,
|
||||
)),
|
||||
organic::types::Object::FootnoteReference(inner) => Ok(
|
||||
IAstNode::FootnoteReference(IFootnoteReference::new(registry, inner).await?),
|
||||
),
|
||||
organic::types::Object::Citation(inner) => {
|
||||
Ok(IAstNode::Citation(ICitation::new(registry, inner).await?))
|
||||
organic::types::Object::FootnoteReference(inner) => {
|
||||
Ok(IAstNode::FootnoteReference(
|
||||
IFootnoteReference::new(intermediate_context, inner).await?,
|
||||
))
|
||||
}
|
||||
organic::types::Object::Citation(inner) => Ok(IAstNode::Citation(
|
||||
ICitation::new(intermediate_context, inner).await?,
|
||||
)),
|
||||
organic::types::Object::CitationReference(inner) => {
|
||||
Ok(IAstNode::CitationReference(
|
||||
ICitationReference::new(intermediate_context, inner).await?,
|
||||
))
|
||||
}
|
||||
organic::types::Object::CitationReference(inner) => Ok(
|
||||
IAstNode::CitationReference(ICitationReference::new(registry, inner).await?),
|
||||
),
|
||||
organic::types::Object::InlineBabelCall(inner) => Ok(IAstNode::InlineBabelCall(
|
||||
IInlineBabelCall::new(registry, inner).await?,
|
||||
IInlineBabelCall::new(intermediate_context, inner).await?,
|
||||
)),
|
||||
organic::types::Object::InlineSourceBlock(inner) => Ok(
|
||||
IAstNode::InlineSourceBlock(IInlineSourceBlock::new(registry, inner).await?),
|
||||
),
|
||||
organic::types::Object::LineBreak(inner) => {
|
||||
Ok(IAstNode::LineBreak(ILineBreak::new(registry, inner).await?))
|
||||
}
|
||||
organic::types::Object::Target(inner) => {
|
||||
Ok(IAstNode::Target(ITarget::new(registry, inner).await?))
|
||||
organic::types::Object::InlineSourceBlock(inner) => {
|
||||
Ok(IAstNode::InlineSourceBlock(
|
||||
IInlineSourceBlock::new(intermediate_context, inner).await?,
|
||||
))
|
||||
}
|
||||
organic::types::Object::LineBreak(inner) => Ok(IAstNode::LineBreak(
|
||||
ILineBreak::new(intermediate_context, inner).await?,
|
||||
)),
|
||||
organic::types::Object::Target(inner) => Ok(IAstNode::Target(
|
||||
ITarget::new(intermediate_context, inner).await?,
|
||||
)),
|
||||
organic::types::Object::StatisticsCookie(inner) => Ok(IAstNode::StatisticsCookie(
|
||||
IStatisticsCookie::new(registry, inner).await?,
|
||||
IStatisticsCookie::new(intermediate_context, inner).await?,
|
||||
)),
|
||||
organic::types::Object::Subscript(inner) => Ok(IAstNode::Subscript(
|
||||
ISubscript::new(intermediate_context, inner).await?,
|
||||
)),
|
||||
organic::types::Object::Subscript(inner) => {
|
||||
Ok(IAstNode::Subscript(ISubscript::new(registry, inner).await?))
|
||||
}
|
||||
organic::types::Object::Superscript(inner) => Ok(IAstNode::Superscript(
|
||||
ISuperscript::new(registry, inner).await?,
|
||||
ISuperscript::new(intermediate_context, inner).await?,
|
||||
)),
|
||||
organic::types::Object::Timestamp(inner) => Ok(IAstNode::Timestamp(
|
||||
ITimestamp::new(intermediate_context, inner).await?,
|
||||
)),
|
||||
organic::types::Object::Timestamp(inner) => {
|
||||
Ok(IAstNode::Timestamp(ITimestamp::new(registry, inner).await?))
|
||||
}
|
||||
}
|
||||
}
|
||||
.boxed()
|
||||
|
||||
Reference in New Issue
Block a user