Create artificial scopes for the optional value and mandatory value.
This commit is contained in:
parent
dff7550038
commit
8bc942a26f
@ -460,7 +460,7 @@ pub(crate) fn compare_property_list_of_list_of_list_of_ast_nodes<
|
|||||||
(Some(value), Some(rust_value)) => (value, rust_value),
|
(Some(value), Some(rust_value)) => (value, rust_value),
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut child_status: Vec<DiffEntry<'b, 's>> = Vec::with_capacity(rust_value.len());
|
let mut full_status: Vec<DiffEntry<'b, 's>> = Vec::with_capacity(rust_value.len());
|
||||||
|
|
||||||
// Iterate the outer lists
|
// Iterate the outer lists
|
||||||
for (value, (rust_optional, rust_value)) in value.iter().zip(rust_value.iter()) {
|
for (value, (rust_optional, rust_value)) in value.iter().zip(rust_value.iter()) {
|
||||||
@ -481,6 +481,7 @@ pub(crate) fn compare_property_list_of_list_of_list_of_ast_nodes<
|
|||||||
|
|
||||||
// Compare optional value
|
// Compare optional value
|
||||||
if let Some(rust_optional) = rust_optional {
|
if let Some(rust_optional) = rust_optional {
|
||||||
|
let mut child_status: Vec<DiffEntry<'b, 's>> = Vec::with_capacity(rust_value.len());
|
||||||
if rust_optional.len() != middle_value.len() {
|
if rust_optional.len() != middle_value.len() {
|
||||||
let this_status = DiffStatus::Bad;
|
let this_status = DiffStatus::Bad;
|
||||||
let message = Some(format!(
|
let message = Some(format!(
|
||||||
@ -495,9 +496,14 @@ pub(crate) fn compare_property_list_of_list_of_list_of_ast_nodes<
|
|||||||
for (e, r) in middle_value.zip(rust_optional) {
|
for (e, r) in middle_value.zip(rust_optional) {
|
||||||
child_status.push(compare_ast_node(source, e, r.into())?);
|
child_status.push(compare_ast_node(source, e, r.into())?);
|
||||||
}
|
}
|
||||||
|
if !child_status.is_empty() {
|
||||||
|
let diff_scope = artificial_diff_scope("optional value", child_status)?;
|
||||||
|
full_status.push(diff_scope);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compare mandatory value
|
// Compare mandatory value
|
||||||
|
let mut child_status: Vec<DiffEntry<'b, 's>> = Vec::with_capacity(rust_value.len());
|
||||||
let mandatory_value = mandatory_value.as_list()?;
|
let mandatory_value = mandatory_value.as_list()?;
|
||||||
if rust_value.len() != mandatory_value.len() {
|
if rust_value.len() != mandatory_value.len() {
|
||||||
let this_status = DiffStatus::Bad;
|
let this_status = DiffStatus::Bad;
|
||||||
@ -513,11 +519,15 @@ pub(crate) fn compare_property_list_of_list_of_list_of_ast_nodes<
|
|||||||
for (e, r) in mandatory_value.iter().zip(rust_value) {
|
for (e, r) in mandatory_value.iter().zip(rust_value) {
|
||||||
child_status.push(compare_ast_node(source, e, r.into())?);
|
child_status.push(compare_ast_node(source, e, r.into())?);
|
||||||
}
|
}
|
||||||
|
if !child_status.is_empty() {
|
||||||
|
let diff_scope = artificial_diff_scope("mandatory value", child_status)?;
|
||||||
|
full_status.push(diff_scope);
|
||||||
}
|
}
|
||||||
if child_status.is_empty() {
|
}
|
||||||
|
if full_status.is_empty() {
|
||||||
Ok(ComparePropertiesResult::NoChange)
|
Ok(ComparePropertiesResult::NoChange)
|
||||||
} else {
|
} else {
|
||||||
let diff_scope = artificial_owned_diff_scope(emacs_field, child_status)?;
|
let diff_scope = artificial_owned_diff_scope(emacs_field, full_status)?;
|
||||||
Ok(ComparePropertiesResult::DiffEntry(diff_scope))
|
Ok(ComparePropertiesResult::DiffEntry(diff_scope))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user