Compare radio link properties.
This commit is contained in:
parent
dfad7b7888
commit
8d621b32dc
@ -2758,11 +2758,13 @@ fn compare_strike_through<'b, 's>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn compare_regular_link<'b, 's>(
|
fn compare_regular_link<'b, 's>(
|
||||||
_source: &'s str,
|
source: &'s str,
|
||||||
emacs: &'b Token<'s>,
|
emacs: &'b Token<'s>,
|
||||||
rust: &'b RegularLink<'s>,
|
rust: &'b RegularLink<'s>,
|
||||||
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
|
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
|
||||||
|
let children = emacs.as_list()?;
|
||||||
let mut this_status = DiffStatus::Good;
|
let mut this_status = DiffStatus::Good;
|
||||||
|
let mut child_status = Vec::new();
|
||||||
let mut message = None;
|
let mut message = None;
|
||||||
|
|
||||||
if let Some((new_status, new_message)) = compare_properties!(
|
if let Some((new_status, new_message)) = compare_properties!(
|
||||||
@ -2812,6 +2814,10 @@ fn compare_regular_link<'b, 's>(
|
|||||||
message = new_message;
|
message = new_message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (emacs_child, rust_child) in children.iter().skip(2).zip(rust.children.iter()) {
|
||||||
|
child_status.push(compare_ast_node(source, emacs_child, rust_child.into())?);
|
||||||
|
}
|
||||||
|
|
||||||
Ok(DiffResult {
|
Ok(DiffResult {
|
||||||
status: this_status,
|
status: this_status,
|
||||||
name: rust.get_elisp_name(),
|
name: rust.get_elisp_name(),
|
||||||
@ -2824,14 +2830,56 @@ fn compare_regular_link<'b, 's>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn compare_radio_link<'b, 's>(
|
fn compare_radio_link<'b, 's>(
|
||||||
_source: &'s str,
|
source: &'s str,
|
||||||
emacs: &'b Token<'s>,
|
emacs: &'b Token<'s>,
|
||||||
rust: &'b RadioLink<'s>,
|
rust: &'b RadioLink<'s>,
|
||||||
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
|
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
|
||||||
let this_status = DiffStatus::Good;
|
let children = emacs.as_list()?;
|
||||||
let message = None;
|
let mut this_status = DiffStatus::Good;
|
||||||
|
let mut child_status = Vec::new();
|
||||||
|
let mut message = None;
|
||||||
|
|
||||||
// TODO: Compare :type :path :format :raw-link :application :search-option
|
if let Some((new_status, new_message)) = compare_properties!(
|
||||||
|
emacs,
|
||||||
|
rust,
|
||||||
|
(
|
||||||
|
EmacsField::Required(":type"),
|
||||||
|
|_| { Some("radio") },
|
||||||
|
compare_property_quoted_string
|
||||||
|
),
|
||||||
|
(
|
||||||
|
EmacsField::Required(":path"),
|
||||||
|
|r| Some(&r.path),
|
||||||
|
compare_property_quoted_string
|
||||||
|
),
|
||||||
|
(
|
||||||
|
EmacsField::Required(":format"),
|
||||||
|
|_| Some("plain"),
|
||||||
|
compare_property_unquoted_atom
|
||||||
|
),
|
||||||
|
(
|
||||||
|
EmacsField::Required(":raw-link"),
|
||||||
|
|r| Some(&r.raw_link),
|
||||||
|
compare_property_quoted_string
|
||||||
|
),
|
||||||
|
(
|
||||||
|
EmacsField::Required(":application"),
|
||||||
|
compare_identity,
|
||||||
|
compare_property_always_nil
|
||||||
|
),
|
||||||
|
(
|
||||||
|
EmacsField::Required(":search-option"),
|
||||||
|
compare_identity,
|
||||||
|
compare_property_always_nil
|
||||||
|
)
|
||||||
|
)? {
|
||||||
|
this_status = new_status;
|
||||||
|
message = new_message;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (emacs_child, rust_child) in children.iter().skip(2).zip(rust.children.iter()) {
|
||||||
|
child_status.push(compare_ast_node(source, emacs_child, rust_child.into())?);
|
||||||
|
}
|
||||||
|
|
||||||
Ok(DiffResult {
|
Ok(DiffResult {
|
||||||
status: this_status,
|
status: this_status,
|
||||||
|
@ -30,6 +30,7 @@ pub(crate) fn radio_link<'b, 'g, 'r, 's>(
|
|||||||
for radio_target in &context.get_global_settings().radio_targets {
|
for radio_target in &context.get_global_settings().radio_targets {
|
||||||
let rematched_target = rematch_target(context, radio_target, input);
|
let rematched_target = rematch_target(context, radio_target, input);
|
||||||
if let Ok((remaining, rematched_target)) = rematched_target {
|
if let Ok((remaining, rematched_target)) = rematched_target {
|
||||||
|
let path = get_consumed(input, remaining);
|
||||||
let (remaining, _) = space0(remaining)?;
|
let (remaining, _) = space0(remaining)?;
|
||||||
let source = get_consumed(input, remaining);
|
let source = get_consumed(input, remaining);
|
||||||
return Ok((
|
return Ok((
|
||||||
@ -37,6 +38,8 @@ pub(crate) fn radio_link<'b, 'g, 'r, 's>(
|
|||||||
RadioLink {
|
RadioLink {
|
||||||
source: source.into(),
|
source: source.into(),
|
||||||
children: rematched_target,
|
children: rematched_target,
|
||||||
|
path: path.into(),
|
||||||
|
raw_link: path.into(),
|
||||||
},
|
},
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -68,6 +68,7 @@ fn regular_link_without_description<'b, 'g, 'r, 's>(
|
|||||||
path: path.path,
|
path: path.path,
|
||||||
raw_link: path.raw_link,
|
raw_link: path.raw_link,
|
||||||
search_option: path.search_option,
|
search_option: path.search_option,
|
||||||
|
children: Vec::new(),
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
@ -80,7 +81,7 @@ fn regular_link_with_description<'b, 'g, 'r, 's>(
|
|||||||
let (remaining, _opening_bracket) = tag("[[")(input)?;
|
let (remaining, _opening_bracket) = tag("[[")(input)?;
|
||||||
let (remaining, path) = pathreg(context, remaining)?;
|
let (remaining, path) = pathreg(context, remaining)?;
|
||||||
let (remaining, _closing_bracket) = tag("][")(remaining)?;
|
let (remaining, _closing_bracket) = tag("][")(remaining)?;
|
||||||
let (remaining, _description) = description(context, remaining)?;
|
let (remaining, description) = description(context, remaining)?;
|
||||||
let (remaining, _closing_bracket) = tag("]]")(remaining)?;
|
let (remaining, _closing_bracket) = tag("]]")(remaining)?;
|
||||||
let (remaining, _trailing_whitespace) =
|
let (remaining, _trailing_whitespace) =
|
||||||
maybe_consume_object_trailing_whitespace_if_not_exiting(context, remaining)?;
|
maybe_consume_object_trailing_whitespace_if_not_exiting(context, remaining)?;
|
||||||
@ -93,6 +94,7 @@ fn regular_link_with_description<'b, 'g, 'r, 's>(
|
|||||||
path: path.path,
|
path: path.path,
|
||||||
raw_link: path.raw_link,
|
raw_link: path.raw_link,
|
||||||
search_option: path.search_option,
|
search_option: path.search_option,
|
||||||
|
children: description,
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
@ -84,6 +84,7 @@ pub struct RegularLink<'s> {
|
|||||||
pub path: Cow<'s, str>,
|
pub path: Cow<'s, str>,
|
||||||
pub raw_link: Cow<'s, str>,
|
pub raw_link: Cow<'s, str>,
|
||||||
pub search_option: Option<Cow<'s, str>>,
|
pub search_option: Option<Cow<'s, str>>,
|
||||||
|
pub children: Vec<Object<'s>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
@ -95,6 +96,8 @@ pub struct RadioTarget<'s> {
|
|||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
pub struct RadioLink<'s> {
|
pub struct RadioLink<'s> {
|
||||||
pub source: &'s str,
|
pub source: &'s str,
|
||||||
|
pub path: Cow<'s, str>,
|
||||||
|
pub raw_link: Cow<'s, str>,
|
||||||
pub children: Vec<Object<'s>>,
|
pub children: Vec<Object<'s>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user