def testSubtype(self): pytree_utils.AppendNodeAnnotation(self._leaf, pytree_utils.Annotation.SUBTYPE, _FOO) self.assertSetEqual( pytree_utils.GetNodeAnnotation(self._leaf, pytree_utils.Annotation.SUBTYPE), {_FOO}) pytree_utils.RemoveSubtypeAnnotation(self._leaf, _FOO) self.assertSetEqual( pytree_utils.GetNodeAnnotation(self._leaf, pytree_utils.Annotation.SUBTYPE), set())
def _AppendTokenSubtype(self, node, subtype, force=True): """Append the token's subtype only if it's not already set.""" pytree_utils.AppendNodeAnnotation(node, pytree_utils.Annotation.SUBTYPE, subtype)