]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
driver/0.13.x: Add ChildSymbolRegistrar
authorFlorian Brosch <flo.brosch@gmail.com>
Thu, 21 Jul 2011 20:38:04 +0000 (22:38 +0200)
committerFlorian Brosch <flo.brosch@gmail.com>
Fri, 29 Jul 2011 00:45:25 +0000 (02:45 +0200)
src/driver/0.13.x/Makefile.am
src/driver/0.13.x/childsymbolregistrar.vala [new file with mode: 0644]
src/driver/0.13.x/driver.vala
src/driver/0.13.x/symbolresolver.vala
src/driver/0.13.x/treebuilder.vala

index 986dd79b9599df20af4f99aaa852586c16eb94e7..6ad468dbbd77bdae6c4d8ebf7fdbae3d28c9144c 100755 (executable)
@@ -27,6 +27,7 @@ doclet_LTLIBRARIES =  \
 
 libdriver_la_VALASOURCES = \
        initializerbuilder.vala \
+       childsymbolregistrar.vala \
        symbolresolver.vala \
        treebuilder.vala \
        driver.vala \
diff --git a/src/driver/0.13.x/childsymbolregistrar.vala b/src/driver/0.13.x/childsymbolregistrar.vala
new file mode 100644 (file)
index 0000000..2454242
--- /dev/null
@@ -0,0 +1,95 @@
+/* childsymbolregistrar.vala
+ *
+ * Copyright (C) 2011  Florian Brosch
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+ *
+ * Author:
+ *     Florian Brosch <flo.brosch@gmail.com>
+ */
+
+using Valadoc.Api;
+using Gee;
+
+
+public class Valadoc.Drivers.ChildSymbolRegistrar : Visitor {
+       /**
+        * {@inheritDoc}
+        */
+       public override void visit_tree (Api.Tree item) {
+               item.accept_children (this);                    
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public override void visit_package (Package item) {
+               item.accept_all_children (this);
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public override void visit_namespace (Namespace item) {
+               item.accept_all_children (this);
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public override void visit_interface (Interface item) {
+               Collection<TypeReference> interfaces = item.get_implemented_interface_list ();
+               foreach (var type_ref in interfaces) {
+                       ((Interface) type_ref.data_type).register_related_interface (item);
+               }
+
+               if (item.base_type != null) {
+                       ((Class) item.base_type.data_type).register_derived_interface (item);
+               }
+
+               item.accept_all_children (this);
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public override void visit_class (Class item) {
+               Collection<TypeReference> interfaces = item.get_implemented_interface_list ();
+               foreach (TypeReference type_ref in interfaces) {
+                       ((Interface) type_ref.data_type).register_implementation (item);
+               }
+
+               if (item.base_type != null)     {
+                       ((Class) item.base_type.data_type).register_child_class (item);
+               }
+
+               item.accept_all_children (this);
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public override void visit_struct (Struct item) {
+               item.accept_all_children (this);
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public override void visit_property (Property item) {
+               item.accept_all_children (this);
+       }
+}
+
index d5e8e7273ccae09981e50b13fd48b798825d81e3..4bbb940500caac9549d55864b280ce61d09c125b 100755 (executable)
@@ -40,6 +40,9 @@ public class Valadoc.Drivers.Driver : Object, Valadoc.Driver {
                SymbolResolver resolver = new SymbolResolver (builder);
                tree.accept (resolver);
 
+               ChildSymbolRegistrar registrar = new ChildSymbolRegistrar ();
+               tree.accept (registrar);
+
                return tree;
        }
 }
index f227cd0b1a5c3a895c4b0de6a0beba7d1c75eb80..ebc6d6618506c0571feddc511e9a096cad10da9d 100644 (file)
@@ -123,13 +123,10 @@ public class Valadoc.Drivers.SymbolResolver : Visitor {
                Collection<TypeReference> interfaces = item.get_implemented_interface_list ();
                foreach (var type_ref in interfaces) {
                        resolve_type_reference (type_ref);
-                       ((Interface) type_ref.data_type).register_related_interface (item);
                }
 
-
                if (item.base_type != null) {
                        resolve_type_reference (item.base_type);
-                       ((Class) item.base_type.data_type).register_derived_interface (item);
                }
 
                item.accept_all_children (this, false);
@@ -142,12 +139,10 @@ public class Valadoc.Drivers.SymbolResolver : Visitor {
                Collection<TypeReference> interfaces = item.get_implemented_interface_list ();
                foreach (TypeReference type_ref in interfaces) {
                        resolve_type_reference (type_ref);
-                       ((Interface) type_ref.data_type).register_implementation (item);
                }
 
                if (item.base_type != null)     {
                        resolve_type_reference (item.base_type);
-                       ((Class) item.base_type.data_type).register_child_class (item);
                }
 
                item.accept_all_children (this, false);
index 9a10c1b76c795a52c8910145ac4b5152d52ea5d4..2accc7a70ceaa675854713f25cb3e6de8f04d92c 100644 (file)
@@ -689,8 +689,10 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
 
                        if (vala_type_ref.data_type is Vala.Interface) {
                                node.add_interface (type_ref);
-                       } else {
+                       } else if (vala_type_ref.data_type is Vala.Class) {
                                node.base_type = type_ref;
+                       } else {
+                               assert_not_reached ();
                        }
                }