[gnome-builder/wip/slaf/xml-pack: 42/56] xml-pack: better IdeXmlSymbolNode print
- From: Sébastien Lafargue <slafargue src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/slaf/xml-pack: 42/56] xml-pack: better IdeXmlSymbolNode print
- Date: Thu, 13 Jul 2017 12:22:33 +0000 (UTC)
commit cfbe5437bd3e12041c3190a16100295252a19bbd
Author: Sebastien Lafargue <slafargue gnome org>
Date: Tue Jun 27 23:39:21 2017 +0200
xml-pack: better IdeXmlSymbolNode print
plugins/xml-pack/ide-xml-symbol-node.c | 41 ++++++++++++++++++-------
plugins/xml-pack/ide-xml-symbol-node.h | 2 +
plugins/xml-pack/ide-xml-tree-builder-utils.c | 37 ----------------------
3 files changed, 32 insertions(+), 48 deletions(-)
---
diff --git a/plugins/xml-pack/ide-xml-symbol-node.c b/plugins/xml-pack/ide-xml-symbol-node.c
index 35cc1eb..b58795c 100644
--- a/plugins/xml-pack/ide-xml-symbol-node.c
+++ b/plugins/xml-pack/ide-xml-symbol-node.c
@@ -622,16 +622,17 @@ is_in_range (NodeRange range,
static void
print_node_ranges (IdeXmlSymbolNode *node)
{
- printf ("%s (%i,%i)->(%i,%i) end: (%i,%i)->(%i,%i)\n",
- node->element_name,
+ printf ("(%i,%i)->(%i,%i) s:%ld end: (%i,%i)->(%i,%i) s:%ld\n",
node->start_tag.start_line,
node->start_tag.start_line_offset,
node->start_tag.end_line,
node->start_tag.end_line_offset,
+ node->start_tag.size,
node->end_tag.start_line,
node->end_tag.start_line_offset,
node->end_tag.end_line,
- node->end_tag.end_line_offset);
+ node->end_tag.end_line_offset,
+ node->end_tag.size);
}
/* Find the relative position of the (line, line_offset) cursor
@@ -686,29 +687,47 @@ ide_xml_symbol_node_get_attributes_names (IdeXmlSymbolNode *self)
void
ide_xml_symbol_node_print (IdeXmlSymbolNode *self,
+ guint depth,
+ gboolean recurse,
gboolean show_value,
gboolean show_attributes)
{
+ g_autofree gchar *spacer;
gchar **attributes = self->attributes_names;
+ guint n_children;
+ IdeXmlSymbolNode *child;
g_return_if_fail (IDE_IS_XML_SYMBOL_NODE (self));
- printf ("%s(%d:%d->%d:%d)-(%d:%d->%d:%d)\n",
- self->element_name,
- self->start_tag.start_line, self->start_tag.start_line_offset,
- self->start_tag.end_line, self->start_tag.end_line_offset,
- self->end_tag.start_line, self->end_tag.start_line_offset,
- self->end_tag.end_line, self->end_tag.end_line_offset);
+ if (self == NULL)
+ {
+ g_warning ("Node NULL");
+ return;
+ }
+
+ spacer = g_strnfill (depth, '\t');
+ printf ("%s%s state:%d ", spacer, self->element_name, self->state);
+ print_node_ranges (self);
if (show_attributes && self->attributes_names != NULL)
while (*attributes != NULL)
{
- printf ("%s\n", *attributes);
+ printf ("%s%s\n", spacer, *attributes);
++attributes;
}
if (show_value && self->value != NULL)
- printf ("\t%s\n", self->value);
+ printf ("%svalue:%s\n", spacer, self->value);
+
+ if (recurse)
+ {
+ n_children = ide_xml_symbol_node_get_n_direct_children (self);
+ for (gint i = 0; i < n_children; ++i)
+ {
+ child = (IdeXmlSymbolNode *)ide_xml_symbol_node_get_nth_direct_child (self, i);
+ ide_xml_symbol_node_print (child, depth + 1, recurse, show_value, show_attributes);
+ }
+ }
}
const gchar *
diff --git a/plugins/xml-pack/ide-xml-symbol-node.h b/plugins/xml-pack/ide-xml-symbol-node.h
index 5747b83..9a15b80 100644
--- a/plugins/xml-pack/ide-xml-symbol-node.h
+++ b/plugins/xml-pack/ide-xml-symbol-node.h
@@ -89,6 +89,8 @@ IdeXmlSymbolNodeState ide_xml_symbol_node_get_state
const gchar *ide_xml_symbol_node_get_value (IdeXmlSymbolNode
*self);
gboolean ide_xml_symbol_node_has_end_tag (IdeXmlSymbolNode
*self);
void ide_xml_symbol_node_print (IdeXmlSymbolNode
*self,
+ guint
depth,
+ gboolean
recurse,
gboolean
show_value,
gboolean
show_attributes);
void ide_xml_symbol_node_set_location (IdeXmlSymbolNode
*self,
diff --git a/plugins/xml-pack/ide-xml-tree-builder-utils.c b/plugins/xml-pack/ide-xml-tree-builder-utils.c
index 4bcf1e1..c49c20c 100644
--- a/plugins/xml-pack/ide-xml-tree-builder-utils.c
+++ b/plugins/xml-pack/ide-xml-tree-builder-utils.c
@@ -22,43 +22,6 @@
#define HREF_LEN 6
-void
-print_node (IdeXmlSymbolNode *node,
- guint depth)
-{
- g_autofree gchar *spacer;
- gint start_line;
- gint start_line_offset;
- gint end_line;
- gint end_line_offset;
- gsize size;
-
- g_return_if_fail (IDE_IS_XML_SYMBOL_NODE (node) || node == NULL);
-
- if (node == NULL)
- {
- g_warning ("Node NULL");
- return;
- }
-
- spacer = g_strnfill (depth, '\t');
- ide_xml_symbol_node_get_location (node,
- &start_line, &start_line_offset,
- &end_line, &end_line_offset,
- &size);
-
- printf ("%s%s (%i) at (%i,%i)-(%i,%i) size:%li %p\n",
- spacer,
- ide_symbol_node_get_name (IDE_SYMBOL_NODE (node)),
- depth,
- start_line,
- start_line_offset,
- end_line,
- end_line_offset,
- size,
- node);
-}
-
const gchar *
list_get_attribute (const guchar **attributes,
const gchar *name)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]