Compare commits
6 Commits
a4a83d047d
...
c1b471208d
Author | SHA1 | Date | |
---|---|---|---|
![]() |
c1b471208d | ||
![]() |
606bab9e6d | ||
![]() |
0edf5620a2 | ||
![]() |
cdf87641c5 | ||
![]() |
eb2995dd3b | ||
![]() |
cd6a64c015 |
@ -4,15 +4,13 @@ use serde::Serialize;
|
|||||||
use super::ast_node::WasmAstNode;
|
use super::ast_node::WasmAstNode;
|
||||||
use super::macros::to_wasm;
|
use super::macros::to_wasm;
|
||||||
use super::to_wasm::ToWasm;
|
use super::to_wasm::ToWasm;
|
||||||
use super::AdditionalProperties;
|
|
||||||
use crate::compare::ElispFact;
|
use crate::compare::ElispFact;
|
||||||
use crate::types::Comment;
|
use crate::types::Comment;
|
||||||
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
pub struct WasmComment {
|
pub struct WasmComment {
|
||||||
#[serde(flatten)]
|
pub(crate) value: String,
|
||||||
pub(crate) additional_properties: AdditionalProperties,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
to_wasm!(
|
to_wasm!(
|
||||||
@ -21,12 +19,12 @@ to_wasm!(
|
|||||||
original,
|
original,
|
||||||
wasm_context,
|
wasm_context,
|
||||||
{ WasmAstNode::Comment(original) },
|
{ WasmAstNode::Comment(original) },
|
||||||
{ "TODO".into() },
|
{ "comment".into() },
|
||||||
{
|
{
|
||||||
Ok((
|
Ok((
|
||||||
Vec::new(),
|
Vec::new(),
|
||||||
WasmComment {
|
WasmComment {
|
||||||
additional_properties: AdditionalProperties::default(),
|
value: original.get_value(),
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ use super::macros::to_wasm;
|
|||||||
use super::to_wasm::ToWasm;
|
use super::to_wasm::ToWasm;
|
||||||
use super::AdditionalProperties;
|
use super::AdditionalProperties;
|
||||||
use crate::compare::ElispFact;
|
use crate::compare::ElispFact;
|
||||||
|
use crate::types::GetAffiliatedKeywords;
|
||||||
use crate::types::Keyword;
|
use crate::types::Keyword;
|
||||||
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
@ -13,6 +14,8 @@ use crate::wasm::to_wasm::ToWasmStandardProperties;
|
|||||||
pub struct WasmKeyword {
|
pub struct WasmKeyword {
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
pub(crate) additional_properties: AdditionalProperties,
|
pub(crate) additional_properties: AdditionalProperties,
|
||||||
|
pub(crate) key: String,
|
||||||
|
pub(crate) value: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
to_wasm!(
|
to_wasm!(
|
||||||
@ -21,12 +24,18 @@ to_wasm!(
|
|||||||
original,
|
original,
|
||||||
wasm_context,
|
wasm_context,
|
||||||
{ WasmAstNode::Keyword(original) },
|
{ WasmAstNode::Keyword(original) },
|
||||||
{ "TODO".into() },
|
{ "keyword".into() },
|
||||||
{
|
{
|
||||||
|
let additional_properties = original
|
||||||
|
.get_affiliated_keywords()
|
||||||
|
.to_wasm(wasm_context.clone())?;
|
||||||
|
|
||||||
Ok((
|
Ok((
|
||||||
Vec::new(),
|
Vec::new(),
|
||||||
WasmKeyword {
|
WasmKeyword {
|
||||||
additional_properties: AdditionalProperties::default(),
|
additional_properties,
|
||||||
|
key: original.key.to_uppercase(),
|
||||||
|
value: original.value.to_owned(),
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
@ -6,13 +6,17 @@ use super::macros::to_wasm;
|
|||||||
use super::to_wasm::ToWasm;
|
use super::to_wasm::ToWasm;
|
||||||
use super::AdditionalProperties;
|
use super::AdditionalProperties;
|
||||||
use crate::compare::ElispFact;
|
use crate::compare::ElispFact;
|
||||||
|
use crate::types::GetAffiliatedKeywords;
|
||||||
use crate::types::PlainList;
|
use crate::types::PlainList;
|
||||||
|
use crate::types::PlainListType;
|
||||||
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
pub struct WasmPlainList {
|
pub struct WasmPlainList {
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
pub(crate) additional_properties: AdditionalProperties,
|
pub(crate) additional_properties: AdditionalProperties,
|
||||||
|
#[serde(rename = "type")]
|
||||||
|
pub(crate) list_type: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
to_wasm!(
|
to_wasm!(
|
||||||
@ -21,8 +25,12 @@ to_wasm!(
|
|||||||
original,
|
original,
|
||||||
wasm_context,
|
wasm_context,
|
||||||
{ WasmAstNode::PlainList(original) },
|
{ WasmAstNode::PlainList(original) },
|
||||||
{ "TODO".into() },
|
{ "plain-list".into() },
|
||||||
{
|
{
|
||||||
|
let additional_properties = original
|
||||||
|
.get_affiliated_keywords()
|
||||||
|
.to_wasm(wasm_context.clone())?;
|
||||||
|
|
||||||
let children = original
|
let children = original
|
||||||
.children
|
.children
|
||||||
.iter()
|
.iter()
|
||||||
@ -36,7 +44,13 @@ to_wasm!(
|
|||||||
Ok((
|
Ok((
|
||||||
children,
|
children,
|
||||||
WasmPlainList {
|
WasmPlainList {
|
||||||
additional_properties: AdditionalProperties::default(),
|
additional_properties,
|
||||||
|
list_type: match original.list_type {
|
||||||
|
PlainListType::Unordered => "unordered",
|
||||||
|
PlainListType::Ordered => "ordered",
|
||||||
|
PlainListType::Descriptive => "descriptive",
|
||||||
|
}
|
||||||
|
.to_owned(),
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
@ -4,15 +4,20 @@ use serde::Serialize;
|
|||||||
use super::ast_node::WasmAstNode;
|
use super::ast_node::WasmAstNode;
|
||||||
use super::macros::to_wasm;
|
use super::macros::to_wasm;
|
||||||
use super::to_wasm::ToWasm;
|
use super::to_wasm::ToWasm;
|
||||||
use super::AdditionalProperties;
|
|
||||||
use crate::compare::ElispFact;
|
use crate::compare::ElispFact;
|
||||||
|
use crate::types::CheckboxType;
|
||||||
use crate::types::PlainListItem;
|
use crate::types::PlainListItem;
|
||||||
|
use crate::types::PlainListItemCounter;
|
||||||
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
pub struct WasmPlainListItem {
|
pub struct WasmPlainListItem {
|
||||||
#[serde(flatten)]
|
pub(crate) tag: Vec<WasmAstNode>,
|
||||||
pub(crate) additional_properties: AdditionalProperties,
|
pub(crate) bullet: String,
|
||||||
|
pub(crate) counter: Option<PlainListItemCounter>,
|
||||||
|
pub(crate) checkbox: Option<String>,
|
||||||
|
#[serde(rename = "pre-blank")]
|
||||||
|
pub(crate) pre_blank: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
to_wasm!(
|
to_wasm!(
|
||||||
@ -21,7 +26,7 @@ to_wasm!(
|
|||||||
original,
|
original,
|
||||||
wasm_context,
|
wasm_context,
|
||||||
{ WasmAstNode::PlainListItem(original) },
|
{ WasmAstNode::PlainListItem(original) },
|
||||||
{ "TODO".into() },
|
{ "item".into() },
|
||||||
{
|
{
|
||||||
let children = original
|
let children = original
|
||||||
.children
|
.children
|
||||||
@ -36,7 +41,18 @@ to_wasm!(
|
|||||||
Ok((
|
Ok((
|
||||||
children,
|
children,
|
||||||
WasmPlainListItem {
|
WasmPlainListItem {
|
||||||
additional_properties: AdditionalProperties::default(),
|
tag: Vec::new(),
|
||||||
|
bullet: original.bullet.to_owned(),
|
||||||
|
counter: original.counter.clone(),
|
||||||
|
checkbox: original.checkbox.as_ref().map(|(checkbox_type, _)| {
|
||||||
|
match checkbox_type {
|
||||||
|
CheckboxType::On => "on",
|
||||||
|
CheckboxType::Trans => "trans",
|
||||||
|
CheckboxType::Off => "off",
|
||||||
|
}
|
||||||
|
.to_owned()
|
||||||
|
}),
|
||||||
|
pre_blank: 0, // TODO: Should this be a no-op?
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
@ -411,7 +411,7 @@ pub(crate) fn wasm_get_emacs_standard_properties(
|
|||||||
|
|
||||||
fn wasm_compare_list<'e, 's: 'e, 'w, EI, WI>(
|
fn wasm_compare_list<'e, 's: 'e, 'w, EI, WI>(
|
||||||
source: &'s str,
|
source: &'s str,
|
||||||
emacs: EI,
|
mut emacs: EI,
|
||||||
wasm: WI,
|
wasm: WI,
|
||||||
) -> Result<WasmDiffResult<'s>, Box<dyn std::error::Error>>
|
) -> Result<WasmDiffResult<'s>, Box<dyn std::error::Error>>
|
||||||
where
|
where
|
||||||
@ -420,6 +420,11 @@ where
|
|||||||
{
|
{
|
||||||
let emacs_length = emacs.len();
|
let emacs_length = emacs.len();
|
||||||
let wasm_length = wasm.len();
|
let wasm_length = wasm.len();
|
||||||
|
if emacs_length == 1 && wasm_length == 0 {
|
||||||
|
if emacs.all(|t| matches!(t.as_atom(), Ok(r#""""#))) {
|
||||||
|
return Ok(WasmDiffResult::default());
|
||||||
|
}
|
||||||
|
}
|
||||||
if emacs_length != wasm_length {
|
if emacs_length != wasm_length {
|
||||||
return Ok(WasmDiffResult {
|
return Ok(WasmDiffResult {
|
||||||
status: vec![WasmDiffStatus::Bad(
|
status: vec![WasmDiffStatus::Bad(
|
||||||
@ -569,11 +574,11 @@ fn compare_object_tree<'e, 's, 'w>(
|
|||||||
.expect("If-statement proves this will be Some.");
|
.expect("If-statement proves this will be Some.");
|
||||||
result.extend(compare_json_value(source, emacs_val, wasm_val)?)?;
|
result.extend(compare_json_value(source, emacs_val, wasm_val)?)?;
|
||||||
} else {
|
} else {
|
||||||
// If optval is not null, then the emacs array should contain 3 values, the optval, a dot, and the val.
|
// If optval is not null, then the emacs array should contain a list, the first child of which is a list for optval, and all other entries to the outer list are the val.
|
||||||
if emacs_attribute.len() != 3 {
|
if emacs_attribute.len() < 2 {
|
||||||
result.status.push(WasmDiffStatus::Bad(
|
result.status.push(WasmDiffStatus::Bad(
|
||||||
format!(
|
format!(
|
||||||
"Emacs middle layer in object tree should have a length of 3. Emacs=({emacs:?}) Wasm=({wasm:?}).",
|
"Emacs middle layer in object tree should have a length of at least 2. Emacs=({emacs:?}) Wasm=({wasm:?}).",
|
||||||
emacs = emacs_attribute,
|
emacs = emacs_attribute,
|
||||||
wasm = wasm_attribute
|
wasm = wasm_attribute
|
||||||
)
|
)
|
||||||
@ -581,20 +586,27 @@ fn compare_object_tree<'e, 's, 'w>(
|
|||||||
));
|
));
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
let emacs_optval = emacs_attribute
|
let emacs_optval = emacs_attribute.iter().skip(1);
|
||||||
.first()
|
|
||||||
.expect("If-statement proves this will be Some.");
|
|
||||||
let wasm_optval = wasm_attribute
|
let wasm_optval = wasm_attribute
|
||||||
.first()
|
.first()
|
||||||
.expect("If-statement proves this will be Some.");
|
.expect("If-statement proves this will be Some.")
|
||||||
|
.as_array()
|
||||||
|
.ok_or("first value in wasm object tree should be a list.")?;
|
||||||
let emacs_val = emacs_attribute
|
let emacs_val = emacs_attribute
|
||||||
.get(2)
|
.first()
|
||||||
.expect("If-statement proves this will be Some.");
|
.ok_or("If-statement proves this will be Some.")?
|
||||||
|
.as_list()?;
|
||||||
let wasm_val = wasm_attribute
|
let wasm_val = wasm_attribute
|
||||||
.get(1)
|
.get(1)
|
||||||
.expect("If-statement proves this will be Some.");
|
.expect("If-statement proves this will be Some.")
|
||||||
result.extend(compare_json_value(source, emacs_optval, wasm_optval)?)?;
|
.as_array()
|
||||||
result.extend(compare_json_value(source, emacs_val, wasm_val)?)?;
|
.ok_or("2nd value in wasm object tree should be a list.")?;
|
||||||
|
result.extend(wasm_compare_list(source, emacs_optval, wasm_optval.iter())?)?;
|
||||||
|
result.extend(wasm_compare_list(
|
||||||
|
source,
|
||||||
|
emacs_val.iter(),
|
||||||
|
wasm_val.iter(),
|
||||||
|
)?)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user