Switch to putting radio targets in the global settings instead of the context tree.
This commit is contained in:
@@ -1,16 +1,19 @@
|
||||
#[derive(Debug)]
|
||||
pub struct GlobalSettings<'s> {
|
||||
#[allow(dead_code)]
|
||||
placeholder: Option<&'s str>,
|
||||
use crate::types::Object;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct GlobalSettings<'g, 's> {
|
||||
pub radio_targets: Vec<&'g Vec<Object<'s>>>,
|
||||
}
|
||||
|
||||
impl<'s> GlobalSettings<'s> {
|
||||
impl<'g, 's> GlobalSettings<'g, 's> {
|
||||
pub fn new() -> Self {
|
||||
GlobalSettings { placeholder: None }
|
||||
GlobalSettings {
|
||||
radio_targets: Vec::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Default for GlobalSettings<'s> {
|
||||
impl<'g, 's> Default for GlobalSettings<'g, 's> {
|
||||
fn default() -> Self {
|
||||
GlobalSettings::new()
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
use std::marker::PhantomData;
|
||||
|
||||
use nom::combinator::eof;
|
||||
use nom::IResult;
|
||||
|
||||
@@ -10,7 +12,6 @@ use crate::error::CustomError;
|
||||
use crate::error::MyError;
|
||||
use crate::error::Res;
|
||||
use crate::parser::OrgSource;
|
||||
use crate::types::Object;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum ContextElement<'r, 's> {
|
||||
@@ -23,12 +24,8 @@ pub enum ContextElement<'r, 's> {
|
||||
/// Indicates if elements should consume the whitespace after them.
|
||||
ConsumeTrailingWhitespace(bool),
|
||||
|
||||
/// The contents of a radio target.
|
||||
///
|
||||
/// If any are found, this will force a 2nd parse through the
|
||||
/// org-mode document since text needs to be re-parsed to look for
|
||||
/// radio links matching the contents of radio targets.
|
||||
RadioTarget(Vec<&'r Vec<Object<'s>>>),
|
||||
/// This is just here to use the 's lifetime until I'm sure we can eliminate it from ContextElement.
|
||||
Placeholder(PhantomData<&'s str>),
|
||||
}
|
||||
|
||||
pub struct ExitMatcherNode<'r> {
|
||||
@@ -47,13 +44,13 @@ impl<'r> std::fmt::Debug for ExitMatcherNode<'r> {
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Context<'g, 'r, 's> {
|
||||
global_settings: &'g GlobalSettings<'g>,
|
||||
global_settings: &'g GlobalSettings<'g, 's>,
|
||||
tree: List<'r, &'r ContextElement<'r, 's>>,
|
||||
}
|
||||
|
||||
impl<'g, 'r, 's> Context<'g, 'r, 's> {
|
||||
pub fn new(
|
||||
global_settings: &'g GlobalSettings<'g>,
|
||||
global_settings: &'g GlobalSettings<'g, 's>,
|
||||
tree: List<'r, &'r ContextElement<'r, 's>>,
|
||||
) -> Self {
|
||||
Self {
|
||||
@@ -89,6 +86,17 @@ impl<'g, 'r, 's> Context<'g, 'r, 's> {
|
||||
self.tree.get_data()
|
||||
}
|
||||
|
||||
pub fn get_global_settings(&self) -> &'g GlobalSettings<'g, 's> {
|
||||
self.global_settings
|
||||
}
|
||||
|
||||
pub fn with_global_settings<'gg>(&self, new_settings: &'gg GlobalSettings<'gg, 's>) -> Context<'gg, 'r, 's> {
|
||||
Context {
|
||||
global_settings: new_settings,
|
||||
tree: self.tree.clone(),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
pub fn check_exit_matcher(
|
||||
&'r self,
|
||||
@@ -145,7 +153,7 @@ fn document_end<'b, 'g, 'r, 's>(
|
||||
}
|
||||
|
||||
pub struct Iter<'g, 'r, 's> {
|
||||
global_settings: &'g GlobalSettings<'g>,
|
||||
global_settings: &'g GlobalSettings<'g, 's>,
|
||||
next: super::list::IterList<'r, &'r ContextElement<'r, 's>>,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user