[gnome-builder/wip/slaf/xml-pack: 41/56] xml-pack: add a state to IdeXmlSymbolNode



commit 0057a74260b14f98878dd53931cfa8826072843d
Author: Sebastien Lafargue <slafargue gnome org>
Date:   Tue Jun 27 23:34:26 2017 +0200

    xml-pack: add a state to IdeXmlSymbolNode
    
    For now, the main use is identifying if
    a node is closed or not.

 plugins/xml-pack/ide-xml-symbol-node.c |   49 ++++++++++++++++++++++----------
 plugins/xml-pack/ide-xml-symbol-node.h |   10 ++++++
 2 files changed, 44 insertions(+), 15 deletions(-)
---
diff --git a/plugins/xml-pack/ide-xml-symbol-node.c b/plugins/xml-pack/ide-xml-symbol-node.c
index 07bf349..35cc1eb 100644
--- a/plugins/xml-pack/ide-xml-symbol-node.c
+++ b/plugins/xml-pack/ide-xml-symbol-node.c
@@ -38,21 +38,22 @@ typedef struct _NodeRange
 
 struct _IdeXmlSymbolNode
 {
-  IdeSymbolNode      parent_instance;
-
-  IdeXmlSymbolNode  *parent;
-  GArray            *children;
-  gchar             *value;
-  gchar             *element_name;
-  gint               nb_children;
-  gint               nb_internal_children;
-  GFile             *file;
-  gchar            **attributes_names;
-  gchar             *ns;
-  NodeRange          start_tag;
-  NodeRange          end_tag;
-
-  guint              has_end_tag : 1;
+  IdeSymbolNode           parent_instance;
+
+  IdeXmlSymbolNode       *parent;
+  GArray                 *children;
+  gchar                  *value;
+  gchar                  *element_name;
+  gint                    nb_children;
+  gint                    nb_internal_children;
+  GFile                  *file;
+  gchar                 **attributes_names;
+  gchar                  *ns;
+  IdeXmlSymbolNodeState   state;
+  NodeRange               start_tag;
+  NodeRange               end_tag;
+
+  guint                   has_end_tag : 1;
 };
 
 typedef enum
@@ -142,6 +143,7 @@ ide_xml_symbol_node_class_init (IdeXmlSymbolNodeClass *klass)
 static void
 ide_xml_symbol_node_init (IdeXmlSymbolNode *self)
 {
+  self->state = IDE_XML_SYMBOL_NODE_STATE_OK;
 }
 
 IdeXmlSymbolNode *
@@ -555,6 +557,23 @@ ide_xml_symbol_node_set_element_name (IdeXmlSymbolNode *self,
     self->element_name = g_strdup (element_name);
 }
 
+IdeXmlSymbolNodeState
+ide_xml_symbol_node_get_state (IdeXmlSymbolNode *self)
+{
+  g_return_val_if_fail (IDE_IS_XML_SYMBOL_NODE (self),  IDE_XML_SYMBOL_NODE_STATE_UNKNOW);
+
+  return self->state;
+}
+
+void
+ide_xml_symbol_node_set_state (IdeXmlSymbolNode      *self,
+                               IdeXmlSymbolNodeState  state)
+{
+  g_return_if_fail (IDE_IS_XML_SYMBOL_NODE (self));
+
+    self->state = state;
+}
+
 const gchar *
 ide_xml_symbol_node_get_value (IdeXmlSymbolNode *self)
 {
diff --git a/plugins/xml-pack/ide-xml-symbol-node.h b/plugins/xml-pack/ide-xml-symbol-node.h
index b169ad7..5747b83 100644
--- a/plugins/xml-pack/ide-xml-symbol-node.h
+++ b/plugins/xml-pack/ide-xml-symbol-node.h
@@ -40,6 +40,13 @@ typedef enum
   IDE_XML_SYMBOL_NODE_RELATIVE_POSITION_IN_CONTENT
 } IdeXmlSymbolNodeRelativePosition;
 
+typedef enum
+{
+  IDE_XML_SYMBOL_NODE_STATE_UNKNOW,
+  IDE_XML_SYMBOL_NODE_STATE_OK,
+  IDE_XML_SYMBOL_NODE_STATE_NOT_CLOSED
+} IdeXmlSymbolNodeState;
+
 IdeXmlSymbolNode                 *ide_xml_symbol_node_new                           (const gchar            
*name,
                                                                                      const gchar            
*value,
                                                                                      const gchar            
*element_name,
@@ -78,6 +85,7 @@ IdeSymbolNode                    *ide_xml_symbol_node_get_nth_direct_child
 IdeSymbolNode                    *ide_xml_symbol_node_get_nth_internal_child        (IdeXmlSymbolNode       
*self,
                                                                                      guint                   
nth_child);
 IdeXmlSymbolNode                 *ide_xml_symbol_node_get_parent                    (IdeXmlSymbolNode       
*self);
+IdeXmlSymbolNodeState             ide_xml_symbol_node_get_state                     (IdeXmlSymbolNode       
*self);
 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,
@@ -98,6 +106,8 @@ void                              ide_xml_symbol_node_set_end_tag_location
                                                                                      gsize                   
size);
 void                              ide_xml_symbol_node_set_element_name              (IdeXmlSymbolNode       
*self,
                                                                                      const gchar            
*element_name);
+void                              ide_xml_symbol_node_set_state                     (IdeXmlSymbolNode       
*self,
+                                                                                     IdeXmlSymbolNodeState   
state);
 void                              ide_xml_symbol_node_set_value                     (IdeXmlSymbolNode       
*self,
                                                                                      const gchar            
*value);
 const gchar                     **ide_xml_symbol_node_get_attributes_names          (IdeXmlSymbolNode       
*self);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]