Rule.left_sibling and Rule.right_sibling had misleading documentation stating that "no parent" or "inconsistent state" raised ValueError. However, "no parent" raised a different kind of error, while "inconsistent state" was explicitly hidden by the implementation. Fixed "no parent" not to raise, but "inconsistent state" to do raise and error.
Rule.replace, UnparserRule.insert_child, and UnparserRule.add_child did not ensure that the node to be added to the tree was removed from its parent (if it had any). Fixed to remove the added node from its original parent.
Rule.delete got renamed to Rule.remove to better describe its functionality (the node is not deleted, only removed from its parent).
UnparserRule.last_child property setter was removed, since UnparserRule.last_child = ... was equivalent to UnparserRule.last_child.replace(...) (actually, a bit even worse). Even the examples and tests used the latter approach.
UnparserRule's and UnlexerRule's initializers got new arguments to enable the explicit setting of all fields (UnparserRule.children, UnlexerRule.size).
JsonTreeCodec updated to make use of the new initializer arguments.
copy.deepcopy of any node copied the whole tree as it walked along the parent chain by default. Added __copy__ and __deepcopy__ to nodes to explicitly control copying. Shallow copies are disabled, deep copies only copy subtrees (without copying ancestors as well).
coverage: 88.252% (-0.07%) from 88.321%
when pulling 74c58b82f9086cb588b23e1e29463d9d08e6422b on akosthekiss:rule-api-rev
into d7a9a9ef57bce98462dc16d0f6188287fca51b3f on renatahodovan:master.
Rule.left_sibling
andRule.right_sibling
had misleading documentation stating that "no parent" or "inconsistent state" raisedValueError
. However, "no parent" raised a different kind of error, while "inconsistent state" was explicitly hidden by the implementation. Fixed "no parent" not to raise, but "inconsistent state" to do raise and error.Rule.replace
,UnparserRule.insert_child
, andUnparserRule.add_child
did not ensure that the node to be added to the tree was removed from its parent (if it had any). Fixed to remove the added node from its original parent.Rule.delete
got renamed toRule.remove
to better describe its functionality (the node is not deleted, only removed from its parent).UnparserRule.last_child
property setter was removed, sinceUnparserRule.last_child = ...
was equivalent toUnparserRule.last_child.replace(...)
(actually, a bit even worse). Even the examples and tests used the latter approach.UnparserRule's and UnlexerRule's initializers got new arguments to enable the explicit setting of all fields (UnparserRule.children, UnlexerRule.size).
JsonTreeCodec updated to make use of the new initializer arguments.
copy.deepcopy
of any node copied the whole tree as it walked along the parent chain by default. Added__copy__
and__deepcopy__
to nodes to explicitly control copying. Shallow copies are disabled, deep copies only copy subtrees (without copying ancestors as well).