implement anonymous pick or delete of children
...while I must admit that I'm a bit doubtful about that language feature, but it does come in handy when manually writing diff messages. The reason is the automatic naming of child objects, which makes it often hard to refer to a child after the fact, since the name can not be reconstructed systematically. Obviously the downside of this "anonymous pick / delete" is that we allow to pick (accept) or even delete just any child, which happens to sit there, without being able to detect a synchronisation mismatch between sender and receiver.
This commit is contained in:
parent
73eaa10caf
commit
daa13ab6dc
2 changed files with 6 additions and 2 deletions
|
|
@ -129,6 +129,10 @@ namespace diff{
|
|||
throw error::State(_Fmt("Unable to %s element %s from target as demanded; "
|
||||
"no (further) elements in target sequence") % oper % elm
|
||||
, LUMIERA_ERROR_DIFF_CONFLICT);
|
||||
|
||||
if (elm.matches(Ref::CHILD) and not srcPos()->isNamed())
|
||||
return; // allow for anonymous pick or delete of children
|
||||
|
||||
if (not srcPos()->matches(elm))
|
||||
throw error::State(_Fmt("Unable to %s element %s from target as demanded; "
|
||||
"found element %s on current target position instead")
|
||||
|
|
|
|||
|
|
@ -107,12 +107,12 @@ namespace test{
|
|||
DiffSeq
|
||||
mutationDiff()
|
||||
{
|
||||
return snapshot({after(Ref::ATTRIBS)
|
||||
return snapshot({after(Ref::ATTRIBS) // fast forward to the first child
|
||||
, find(CHILD_T)
|
||||
, pick(CHILD_A)
|
||||
, skip(CHILD_T)
|
||||
, del(CHILD_T)
|
||||
, pick(Ref::CHILD)
|
||||
, pick(Ref::CHILD) // pick a child anonymously
|
||||
, mut(Ref::THIS)
|
||||
, ins(ATTRIB3)
|
||||
, ins(ATTRIB_NODE)
|
||||
|
|
|
|||
Loading…
Reference in a new issue