From: Florian Brosch Date: Thu, 21 Jul 2011 20:38:04 +0000 (+0200) Subject: driver/0.13.x: Add ChildSymbolRegistrar X-Git-Tag: 0.37.1~3^2~321 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=d6e4c472c5b0a1b020b06d285d29dd3ef42dd835;p=thirdparty%2Fvala.git driver/0.13.x: Add ChildSymbolRegistrar --- diff --git a/src/driver/0.13.x/Makefile.am b/src/driver/0.13.x/Makefile.am index 986dd79b9..6ad468dbb 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 000000000..2454242bf --- /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 + */ + +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 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 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 d5e8e7273..4bbb94050 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 f227cd0b1..ebc6d6618 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 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 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 9a10c1b76..2accc7a70 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 (); } }