Enable ID printing for root / properly cascade pretty-printing

* Print out the ID of all elements that have children.
* Change it so that instead of appending the dstring of a value node onto the name of the element shown in the IDE, we instead pass the dstring value directly to the pretty-printer framework and let it decide what to do with it. This results in a more consistent look between our irept pretty-printers and a 'normal' pretty printer, and also abstracts away the irep pretty-printer from caring about how things should be shown.

The latter comes with the downside that it is a little harder on the eyes, as it goes '{element name} {type identifier} {string value}', but this is how everything else in the IDE is set up as well.
This commit is contained in:
johndumbell 2019-09-20 13:34:32 +01:00
parent 9887157a67
commit db3778acb7
1 changed files with 15 additions and 4 deletions

View File

@ -72,12 +72,10 @@ def get_node_value(data_ref):
if id_value:
if has_children:
return "[{0}]".format(id_value)
else:
return "\"{0}\"".format(id_value)
elif has_children:
return "[...]"
return "\"\""
return None
def get_id(data_ref):
@ -148,6 +146,13 @@ class IrepPrettyPrinter:
we return a single child with the value of the node.
"""
if has_children_nodes(self.val):
if self.clion_representation:
yield "ID", self.val["data"]
else:
yield "ID key", "ID"
yield "ID value", self.val["data"]
sub = self.val["sub"]
sub_count = 0
item = sub["_M_impl"]["_M_start"]
@ -158,9 +163,12 @@ class IrepPrettyPrinter:
iter_item = item.dereference()
if self.clion_representation:
item_deref = iter_item["data"].referenced_value()
nested_id = get_node_value(iter_item["data"].referenced_value())
if nested_id:
node_key = "{0}: {1}".format(node_key, nested_id)
else:
iter_item = item_deref["data"]
yield node_key, iter_item
else:
@ -188,9 +196,12 @@ class IrepPrettyPrinter:
iter_item = result["second"]
if self.clion_representation:
nested_id = get_node_value(iter_item["data"].referenced_value())
item_deref = iter_item["data"].referenced_value()
nested_id = get_node_value(item_deref)
if nested_id:
node_key = "{0}: {1}".format(node_key, nested_id)
else:
iter_item = item_deref["data"]
yield node_key, iter_item
else: