Merge branch 'inline_babel_properties'
This commit is contained in:
commit
69500837f2
@ -1,3 +1,4 @@
|
|||||||
|
call_foo()
|
||||||
call_foo(arguments)
|
call_foo(arguments)
|
||||||
call_bar[header](arguments)
|
call_bar[header](arguments)
|
||||||
call_baz(arguments)[header]
|
call_baz(arguments)[header]
|
||||||
|
@ -3592,20 +3592,61 @@ fn compare_citation_reference<'b, 's>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn compare_inline_babel_call<'b, 's>(
|
fn compare_inline_babel_call<'b, 's>(
|
||||||
_source: &'s str,
|
source: &'s str,
|
||||||
emacs: &'b Token<'s>,
|
emacs: &'b Token<'s>,
|
||||||
rust: &'b InlineBabelCall<'s>,
|
rust: &'b InlineBabelCall<'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 mut this_status = DiffStatus::Good;
|
||||||
let message = None;
|
let mut child_status = Vec::new();
|
||||||
|
let mut message = None;
|
||||||
|
|
||||||
// TODO: Compare :call :inside-header :arguments :end-header :value
|
assert_no_children(emacs, &mut this_status, &mut message)?;
|
||||||
|
|
||||||
|
for diff in compare_properties!(
|
||||||
|
source,
|
||||||
|
emacs,
|
||||||
|
rust,
|
||||||
|
(
|
||||||
|
EmacsField::Required(":call"),
|
||||||
|
|r| Some(r.call),
|
||||||
|
compare_property_quoted_string
|
||||||
|
),
|
||||||
|
(
|
||||||
|
EmacsField::Required(":inside-header"),
|
||||||
|
|r| r.inside_header,
|
||||||
|
compare_property_quoted_string
|
||||||
|
),
|
||||||
|
(
|
||||||
|
EmacsField::Required(":arguments"),
|
||||||
|
|r| r.arguments,
|
||||||
|
compare_property_quoted_string
|
||||||
|
),
|
||||||
|
(
|
||||||
|
EmacsField::Required(":end-header"),
|
||||||
|
|r| r.end_header,
|
||||||
|
compare_property_quoted_string
|
||||||
|
),
|
||||||
|
(
|
||||||
|
EmacsField::Required(":value"),
|
||||||
|
|r| Some(r.value),
|
||||||
|
compare_property_quoted_string
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
match diff {
|
||||||
|
ComparePropertiesResult::NoChange => {}
|
||||||
|
ComparePropertiesResult::SelfChange(new_status, new_message) => {
|
||||||
|
this_status = new_status;
|
||||||
|
message = new_message
|
||||||
|
}
|
||||||
|
ComparePropertiesResult::DiffEntry(diff_entry) => child_status.push(diff_entry),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Ok(DiffResult {
|
Ok(DiffResult {
|
||||||
status: this_status,
|
status: this_status,
|
||||||
name: rust.get_elisp_name(),
|
name: rust.get_elisp_name(),
|
||||||
message,
|
message,
|
||||||
children: Vec::new(),
|
children: child_status,
|
||||||
rust_source: rust.get_source(),
|
rust_source: rust.get_source(),
|
||||||
emacs_token: emacs,
|
emacs_token: emacs,
|
||||||
}
|
}
|
||||||
|
@ -34,10 +34,11 @@ pub(crate) fn inline_babel_call<'b, 'g, 'r, 's>(
|
|||||||
input: OrgSource<'s>,
|
input: OrgSource<'s>,
|
||||||
) -> Res<OrgSource<'s>, InlineBabelCall<'s>> {
|
) -> Res<OrgSource<'s>, InlineBabelCall<'s>> {
|
||||||
let (remaining, _) = tag_no_case("call_")(input)?;
|
let (remaining, _) = tag_no_case("call_")(input)?;
|
||||||
let (remaining, _name) = name(context, remaining)?;
|
let (remaining, name) = name(context, remaining)?;
|
||||||
let (remaining, _header1) = opt(parser_with_context!(header)(context))(remaining)?;
|
let (remaining, inside_header) = opt(parser_with_context!(header)(context))(remaining)?;
|
||||||
let (remaining, _argument) = argument(context, remaining)?;
|
let (remaining, arguments) = argument(context, remaining)?;
|
||||||
let (remaining, _header2) = opt(parser_with_context!(header)(context))(remaining)?;
|
let (remaining, end_header) = opt(parser_with_context!(header)(context))(remaining)?;
|
||||||
|
let value = get_consumed(input, 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)?;
|
||||||
let source = get_consumed(input, remaining);
|
let source = get_consumed(input, remaining);
|
||||||
@ -45,6 +46,15 @@ pub(crate) fn inline_babel_call<'b, 'g, 'r, 's>(
|
|||||||
remaining,
|
remaining,
|
||||||
InlineBabelCall {
|
InlineBabelCall {
|
||||||
source: source.into(),
|
source: source.into(),
|
||||||
|
value: value.into(),
|
||||||
|
call: name.into(),
|
||||||
|
inside_header: inside_header.map(Into::<&str>::into),
|
||||||
|
arguments: if arguments.len() > 0 {
|
||||||
|
Some(arguments.into())
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
},
|
||||||
|
end_header: end_header.map(Into::<&str>::into),
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
@ -217,6 +217,11 @@ pub struct CitationReference<'s> {
|
|||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
pub struct InlineBabelCall<'s> {
|
pub struct InlineBabelCall<'s> {
|
||||||
pub source: &'s str,
|
pub source: &'s str,
|
||||||
|
pub value: &'s str,
|
||||||
|
pub call: &'s str,
|
||||||
|
pub inside_header: Option<&'s str>,
|
||||||
|
pub arguments: Option<&'s str>,
|
||||||
|
pub end_header: Option<&'s str>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
|
Loading…
Reference in New Issue
Block a user