[valadoc] driver/0.13.x: Add ChildSymbolRegistrar



commit d6e4c472c5b0a1b020b06d285d29dd3ef42dd835
Author: Florian Brosch <flo brosch gmail com>
Date:   Thu Jul 21 22:38:04 2011 +0200

    driver/0.13.x: Add ChildSymbolRegistrar

 src/driver/0.13.x/Makefile.am               |    1 +
 src/driver/0.13.x/childsymbolregistrar.vala |   95 +++++++++++++++++++++++++++
 src/driver/0.13.x/driver.vala               |    3 +
 src/driver/0.13.x/symbolresolver.vala       |    5 --
 src/driver/0.13.x/treebuilder.vala          |    4 +-
 5 files changed, 102 insertions(+), 6 deletions(-)
---
diff --git a/src/driver/0.13.x/Makefile.am b/src/driver/0.13.x/Makefile.am
index 986dd79..6ad468d 100755
--- a/src/driver/0.13.x/Makefile.am
+++ b/src/driver/0.13.x/Makefile.am
@@ -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
index 0000000..2454242
--- /dev/null
+++ b/src/driver/0.13.x/childsymbolregistrar.vala
@@ -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);
+	}
+}
+
diff --git a/src/driver/0.13.x/driver.vala b/src/driver/0.13.x/driver.vala
index d5e8e72..4bbb940 100755
--- a/src/driver/0.13.x/driver.vala
+++ b/src/driver/0.13.x/driver.vala
@@ -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;
 	}
 }
diff --git a/src/driver/0.13.x/symbolresolver.vala b/src/driver/0.13.x/symbolresolver.vala
index f227cd0..ebc6d66 100644
--- a/src/driver/0.13.x/symbolresolver.vala
+++ b/src/driver/0.13.x/symbolresolver.vala
@@ -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);
diff --git a/src/driver/0.13.x/treebuilder.vala b/src/driver/0.13.x/treebuilder.vala
index 9a10c1b..2accc7a 100644
--- a/src/driver/0.13.x/treebuilder.vala
+++ b/src/driver/0.13.x/treebuilder.vala
@@ -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 ();
 			}
 		}
 



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