[valadoc] Api: Externalize nodes creation



commit 0d72f4e305cf97161b4c9bd1aafa6932a3aebfda
Author: Didier 'Ptitjes <ptitjes free fr>
Date:   Wed Oct 14 14:27:31 2009 +0200

    Api: Externalize nodes creation

 src/libvaladoc/Makefile.am                         |    1 +
 src/libvaladoc/apitree/apinodebuilder.vala         |  216 ++++++++++++++++++++
 src/libvaladoc/apitree/apitree.vala                |  103 +---------
 src/libvaladoc/apitree/class.vala                  |   32 +---
 src/libvaladoc/apitree/classhandler.vala           |   11 -
 src/libvaladoc/apitree/constant.vala               |    2 +-
 src/libvaladoc/apitree/constanthandler.vala        |   18 +--
 .../apitree/constructionmethodhandler.vala         |   21 +--
 src/libvaladoc/apitree/delegate.vala               |    5 +-
 src/libvaladoc/apitree/delegatehandler.vala        |   11 -
 src/libvaladoc/apitree/enum.vala                   |   15 +--
 src/libvaladoc/apitree/enumvalue.vala              |    2 +-
 src/libvaladoc/apitree/errorcode.vala              |    2 +-
 src/libvaladoc/apitree/errordomain.vala            |   22 +--
 src/libvaladoc/apitree/errordomainhandler.vala     |   11 -
 src/libvaladoc/apitree/field.vala                  |    2 +-
 src/libvaladoc/apitree/fieldhandler.vala           |   15 +--
 src/libvaladoc/apitree/formalparameter.vala        |    2 +-
 src/libvaladoc/apitree/interface.vala              |   32 +---
 src/libvaladoc/apitree/interfacehandler.vala       |   15 +--
 src/libvaladoc/apitree/method.vala                 |    8 +-
 src/libvaladoc/apitree/methodhandler.vala          |   15 +--
 src/libvaladoc/apitree/package.vala                |    5 +
 src/libvaladoc/apitree/parameterlisthandler.vala   |    7 -
 src/libvaladoc/apitree/property.vala               |    2 +-
 src/libvaladoc/apitree/propertyhandler.vala        |   21 +--
 src/libvaladoc/apitree/signal.vala                 |   11 +-
 src/libvaladoc/apitree/signalhandler.vala          |    9 +-
 src/libvaladoc/apitree/struct.vala                 |   14 +--
 src/libvaladoc/apitree/structhandler.vala          |   15 +--
 .../apitree/templateparameterlisthandler.vala      |    7 -
 src/libvaladoc/apitree/typeparameter.vala          |    2 +-
 32 files changed, 263 insertions(+), 391 deletions(-)
---
diff --git a/src/libvaladoc/Makefile.am b/src/libvaladoc/Makefile.am
index 151fe5a..58471d8 100644
--- a/src/libvaladoc/Makefile.am
+++ b/src/libvaladoc/Makefile.am
@@ -36,6 +36,7 @@ libvaladoc_la_VALASOURCES = \
 	apitree/apiitem.vala \
 	apitree/apimembernode.vala \
 	apitree/apinode.vala \
+	apitree/apinodebuilder.vala \
 	apitree/apisymbolnode.vala \
 	apitree/apitree.vala \
 	apitree/apitypesymbolnode.vala \
diff --git a/src/libvaladoc/apitree/apinodebuilder.vala b/src/libvaladoc/apitree/apinodebuilder.vala
new file mode 100644
index 0000000..5355fa1
--- /dev/null
+++ b/src/libvaladoc/apitree/apinodebuilder.vala
@@ -0,0 +1,216 @@
+/* apinodebuilder.vala
+ * 
+ * Valadoc - a documentation tool for vala.
+ * Copyright (C) 2008-2009 Florian Brosch, Didier Villevalois
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License.
+ * 
+ * This program 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 General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Author:
+ * 	Didier 'Ptitjes Villevalois <ptitjes free fr>
+ */
+
+using Vala;
+using Gee;
+
+internal class Valadoc.Api.NodeBuilder : CodeVisitor {
+	private Settings settings;
+	private Tree root;
+	private Gee.Collection<Package> packages;
+	private Node current_node;
+
+	internal NodeBuilder (Settings settings, Tree root) {
+		this.settings = settings;
+		this.root = root;
+		packages = root.get_package_list ();
+		current_node = null;
+	}
+
+	private void process_children (Node node, Vala.Symbol element) {
+		Node old_node = current_node;
+		current_node = node;
+		element.accept_children (this);
+		current_node = old_node;
+	}
+
+	private Node get_parent_node_for (Vala.Symbol element) {
+		if (current_node != null) {
+			return current_node;
+		}
+
+		Vala.SourceFile source_file = element.source_reference.file;
+		Package package = find_package_for (source_file);
+		Namespace ns = package.get_namespace (element);
+		return ns;
+	}
+
+	private Package? find_package_for (Vala.SourceFile source_file) {
+		foreach (Package package in packages) {
+			if (package.is_package_for_file (source_file))
+				return package;
+		}
+		return null;
+	}
+
+	public override void visit_namespace (Vala.Namespace element) {
+		element.accept_children (this);
+	}
+
+	public override void visit_class (Vala.Class element) {
+		Node parent = get_parent_node_for (element);
+
+		SymbolNode node = new Class (settings, element, parent, root);
+		parent.add_child (node);
+
+		process_children (node, element);
+	}
+
+	public override void visit_interface (Vala.Interface element) {
+		Node parent = get_parent_node_for (element);
+
+		SymbolNode node = new Interface (settings, element, parent, root);
+		parent.add_child (node);
+
+		process_children (node, element);
+	}
+
+	public override void visit_struct (Vala.Struct element) {
+		Node parent = get_parent_node_for (element);
+
+		SymbolNode node = new Struct (settings, element, parent, root);
+		parent.add_child (node);
+
+		process_children (node, element);
+	}
+
+	public override void visit_field (Vala.Field element) {
+		Node parent = get_parent_node_for (element);
+
+		SymbolNode node = new Field (settings, element, parent, root);
+		parent.add_child (node);
+
+		// Process field type
+
+		process_children (node, element);
+	}
+
+	public override void visit_property (Vala.Property element) {
+		Node parent = get_parent_node_for (element);
+
+		SymbolNode node = new Property (settings, element, parent, root);
+		parent.add_child (node);
+
+		// Process property type
+
+		process_children (node, element);
+	}
+
+	public override void visit_method (Vala.Method element) {
+		Node parent = get_parent_node_for (element);
+
+		SymbolNode node = new Method (settings, element, parent, root);
+		parent.add_child (node);
+
+		// Process error types
+		// Process return type
+
+		process_children (node, element);
+	}
+
+	public override void visit_signal (Vala.Signal element) {
+		Node parent = get_parent_node_for (element);
+
+		SymbolNode node = new Signal (settings, element, parent, root);
+		parent.add_child (node);
+
+		// Process return type
+
+		process_children (node, element);
+	}
+
+	public override void visit_delegate (Vala.Delegate element) {
+		Node parent = get_parent_node_for (element);
+
+		SymbolNode node = new Delegate (settings, element, parent, root);
+		parent.add_child (node);
+
+		// Process error types
+		// Process return type
+
+		process_children (node, element);
+	}
+
+	public override void visit_enum (Vala.Enum element) {
+		Node parent = get_parent_node_for (element);
+
+		SymbolNode node = new Enum (settings, element, parent, root);
+		parent.add_child (node);
+
+		process_children (node, element);
+	}
+
+	public override void visit_enum_value (Vala.EnumValue element) {
+		Node parent = get_parent_node_for (element);
+
+		SymbolNode node = new EnumValue (settings, element, parent, root);
+		parent.add_child (node);
+
+		process_children (node, element);
+	}
+
+	public override void visit_constant (Vala.Constant element) {
+		Node parent = get_parent_node_for (element);
+
+		SymbolNode node = new Constant (settings, element, parent, root);
+		parent.add_child (node);
+
+		process_children (node, element);
+	}
+
+	public override void visit_error_domain (Vala.ErrorDomain element) {
+		Node parent = get_parent_node_for (element);
+
+		SymbolNode node = new ErrorDomain (settings, element, parent, root);
+		parent.add_child (node);
+
+		process_children (node, element);
+	}
+
+	public override void visit_error_code (Vala.ErrorCode element) {
+		Node parent = get_parent_node_for (element);
+
+		SymbolNode node = new ErrorCode (settings, element, parent, root);
+		parent.add_child (node);
+
+		process_children (node, element);
+	}
+
+	public override void visit_type_parameter (Vala.TypeParameter element) {
+		Node parent = get_parent_node_for (element);
+
+		SymbolNode node = new TypeParameter (settings, element, parent, root);
+		parent.add_child (node);
+
+		process_children (node, element);
+	}
+
+	public override void visit_formal_parameter (Vala.FormalParameter element) {
+		Node parent = get_parent_node_for (element);
+
+		SymbolNode node = new FormalParameter (settings, element, parent, root);
+		parent.add_child (node);
+
+		process_children (node, element);
+	}
+}
diff --git a/src/libvaladoc/apitree/apitree.vala b/src/libvaladoc/apitree/apitree.vala
index c48d9d2..bf349a6 100644
--- a/src/libvaladoc/apitree/apitree.vala
+++ b/src/libvaladoc/apitree/apitree.vala
@@ -27,7 +27,7 @@ using Gee;
 public Valadoc.Class glib_error = null;
 
 
-public class Valadoc.Tree : Vala.CodeVisitor {
+public class Valadoc.Tree {
 	private Gee.ArrayList<Package> packages = new Gee.ArrayList<Package>();
 	private Package source_package = null;
 	private Valadoc.Settings settings;
@@ -94,106 +94,12 @@ public class Valadoc.Tree : Vala.CodeVisitor {
 	}
 
 	private string[] split_name (string full_name) {
-		string[] params = full_name.split( ".", -1 );
-		int i = 0; while ( params[i] != null ) i++;
+		string[] params = full_name.split (".", -1);
+		int i = 0; while (params[i] != null) i++;
 		params.length = i;
 		return params;
 	}
 
-	public override void visit_namespace ( Vala.Namespace vns ) {
-		vns.accept_children ( this );
-	}
-
-	public override void visit_class ( Vala.Class vcl ) {
-		if ( vcl.parent_symbol is Vala.Namespace == false )
-			return ;
-
-		Vala.SourceFile vfile = vcl.source_reference.file;
-		Package file = this.find_file(vfile);
-		Namespace ns = file.get_namespace (vcl);
-		ns.add_class ( vcl );
-	}
-
-	public override void visit_interface ( Vala.Interface viface ) {
-		if ( viface.parent_symbol is Vala.Namespace == false )
-			return ;
-
-		Vala.SourceFile vfile = viface.source_reference.file;
-		Package file = this.find_file( vfile );
-		Namespace ns = file.get_namespace ( viface );
-		ns.add_interface ( viface );
-	}
-
-	public override void visit_struct ( Vala.Struct vstru ) {
-		if ( vstru.parent_symbol is Vala.Namespace == false )
-			return ;
-
-		Vala.SourceFile vfile = vstru.source_reference.file;
-		Package file = this.find_file( vfile );
-		Namespace ns = file.get_namespace ( vstru );
-		ns.add_struct ( vstru );
-	}
-
-	public override void visit_field ( Vala.Field vf ) {
-		if ( vf.parent_symbol is Vala.Namespace == false )
-			return ;
-
-		Vala.SourceFile vfile = vf.source_reference.file;
-		Package file = this.find_file( vfile );
-		Namespace ns = file.get_namespace ( vf );
-		ns.add_field ( vf );
-	}
-
-	public override void visit_method ( Vala.Method vm ) {
-		if ( vm.parent_symbol is Vala.Namespace == false )
-			return ;
-
-		Vala.SourceFile vfile = vm.source_reference.file;
-		Package file = this.find_file( vfile );
-		Namespace ns = file.get_namespace ( vm );
-		ns.add_method ( vm );
-	}
-
-	public override void visit_delegate ( Vala.Delegate vd ) {
-		if ( vd.parent_symbol is Vala.Namespace == false )
-			return ;
-
-		Vala.SourceFile vfile = vd.source_reference.file;
-		Package file = this.find_file( vfile );
-		Namespace ns = file.get_namespace ( vd );
-		ns.add_delegate ( vd );
-	}
-
-	public override void visit_enum ( Vala.Enum venum ) {
-		if ( venum.parent_symbol is Vala.Namespace == false )
-			return ;
-
-		Vala.SourceFile vfile = venum.source_reference.file;
-		Package file = this.find_file( vfile );
-		Namespace ns = file.get_namespace ( venum );
-		ns.add_enum ( venum );
-	}
-
-	public override void visit_constant ( Vala.Constant vc ) {
-		if ( vc.parent_symbol is Vala.Namespace == false )
-			return ;
-
-		Vala.SourceFile vfile = vc.source_reference.file;
-		Package file = this.find_file( vfile );
-		Namespace ns = file.get_namespace ( vc );
-		ns.add_constant ( vc );
-	}
-
-	public override void visit_error_domain ( Vala.ErrorDomain verrdom ) {
-		if ( verrdom.parent_symbol is Vala.Namespace == false )
-			return ;
-
-		Vala.SourceFile vfile = verrdom.source_reference.file;
-		Package file = this.find_file( vfile );
-		Namespace ns = file.get_namespace ( verrdom );
-		ns.add_error_domain ( verrdom );
-	}
-
 	public Tree ( Valadoc.ErrorReporter reporter, Valadoc.Settings settings) {
 		this.context = new Vala.CodeContext ( );
 		CodeContext.push (context);
@@ -391,7 +297,8 @@ public class Valadoc.Tree : Vala.CodeVisitor {
 			}
 		}
 
-		this.context.accept(this);
+		Api.NodeBuilder builder = new Api.NodeBuilder (settings, this);
+		this.context.accept(builder);
 		this.resolve_type_references ();
 		this.add_dependencies_to_source_package ();
 		return true;
diff --git a/src/libvaladoc/apitree/class.vala b/src/libvaladoc/apitree/class.vala
index 3ca2f57..5119c6c 100644
--- a/src/libvaladoc/apitree/class.vala
+++ b/src/libvaladoc/apitree/class.vala
@@ -27,7 +27,7 @@ public class Valadoc.Class : Api.TypeSymbolNode, ClassHandler, StructHandler, Si
 	private Gee.ArrayList<Interface> interfaces;
 	private Vala.Class vclass;
 
-	public Class (Valadoc.Settings settings, Vala.Class symbol, ClassHandler parent, Tree root) {
+	public Class (Valadoc.Settings settings, Vala.Class symbol, Api.Node parent, Tree root) {
 		base (settings, symbol, parent, root);
 		this.interfaces = new Gee.ArrayList<Interface>();
 
@@ -38,36 +38,6 @@ public class Valadoc.Class : Api.TypeSymbolNode, ClassHandler, StructHandler, Si
 				glib_error = this;
 			}
 		}
-
-		var vtparams = this.vclass.get_type_parameters ();
-		this.set_template_parameter_list ( vtparams );
-
-		Gee.Collection<Vala.Enum> venums = this.vclass.get_enums ();
-		this.add_enums ( venums );
-
-		Gee.Collection<Vala.Delegate> vdelegates = this.vclass.get_delegates ();
-		this.add_delegates ( vdelegates );
-
-		Gee.Collection<Vala.Class> vclasses = this.vclass.get_classes();
-		this.add_classes ( vclasses );
-
-		Gee.Collection<Vala.Struct> vstructs = this.vclass.get_structs();
-		this.add_structs ( vstructs );
-
-		Gee.Collection<Vala.Field> vfields = this.vclass.get_fields();
-		this.add_fields ( vfields );
-
-		Gee.Collection<Vala.Method> vmethods = this.vclass.get_methods ();
-		this.add_methods_and_construction_methods ( vmethods );
-
-		Gee.Collection<Vala.Signal> vsignals = this.vclass.get_signals();
-		this.add_signals ( vsignals );
-
-		Gee.Collection<Vala.Property> vproperties = this.vclass.get_properties();
-		this.add_properties ( vproperties );
-
-		Gee.Collection<Vala.Constant> vconstants = this.vclass.get_constants();
-		this.add_constants ( vconstants );
 	}
 
 	protected Class? base_type {
diff --git a/src/libvaladoc/apitree/classhandler.vala b/src/libvaladoc/apitree/classhandler.vala
index fef2f9d..ed38378 100644
--- a/src/libvaladoc/apitree/classhandler.vala
+++ b/src/libvaladoc/apitree/classhandler.vala
@@ -38,17 +38,6 @@ public interface Valadoc.ClassHandler : Api.Node {
 		return get_children_by_type (Api.NodeType.CLASS);
 	}
 
-	internal void add_class ( Vala.Class vcl ) {
-		Class cl = new Class ( this.settings, vcl, this, this.head );
-		add_child ( cl );
-	}
-
-	public void add_classes ( Gee.Collection<Vala.Class> vclasses ) {
-		foreach ( Vala.Class vcl in vclasses ) {
-			this.add_class ( vcl );
-		}
-	}
-
 	public void visit_classes ( Doclet doclet ) {
 		accept_children_by_type (Api.NodeType.CLASS, doclet);
 	}
diff --git a/src/libvaladoc/apitree/constant.vala b/src/libvaladoc/apitree/constant.vala
index eb667f1..cf6f873 100644
--- a/src/libvaladoc/apitree/constant.vala
+++ b/src/libvaladoc/apitree/constant.vala
@@ -35,7 +35,7 @@ public class Valadoc.Constant : Api.MemberNode, ReturnTypeHandler {
 		return ( this.vconst == vconst );
 	}
 
-	public Constant (Valadoc.Settings settings, Vala.Constant symbol, ConstantHandler parent, Tree root) {
+	public Constant (Valadoc.Settings settings, Vala.Constant symbol, Api.Node parent, Tree root) {
 		base (settings, symbol, parent, root);
 		this.vconst = symbol;
 
diff --git a/src/libvaladoc/apitree/constanthandler.vala b/src/libvaladoc/apitree/constanthandler.vala
index fc11201..c9a152b 100644
--- a/src/libvaladoc/apitree/constanthandler.vala
+++ b/src/libvaladoc/apitree/constanthandler.vala
@@ -17,30 +17,16 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 
-
 using Vala;
 using GLib;
 using Gee;
 
-
 public interface Valadoc.ConstantHandler : Api.Node {
-	public Gee.Collection<Constant> get_constant_list ( ) {
+	public Gee.Collection<Constant> get_constant_list () {
 		return get_children_by_type (Api.NodeType.CONSTANT);
 	}
 
-	internal void add_constants (Gee.Collection<Vala.Constant> vconstants) {
-		foreach (Vala.Constant vc in vconstants) {
-			this.add_constant (vc);
-		}
-	}
-
-	internal void add_constant (Vala.Constant vc) {
-		var tmp = new Constant (this.settings, vc, this, this.head);
-		add_child ( tmp );
-	}
-
-	public void visit_constants ( Doclet doclet ) {
+	public void visit_constants (Doclet doclet) {
 		accept_children_by_type (Api.NodeType.CONSTANT, doclet);
 	}
 }
-
diff --git a/src/libvaladoc/apitree/constructionmethodhandler.vala b/src/libvaladoc/apitree/constructionmethodhandler.vala
index b1d5c10..d54e111 100644
--- a/src/libvaladoc/apitree/constructionmethodhandler.vala
+++ b/src/libvaladoc/apitree/constructionmethodhandler.vala
@@ -17,13 +17,11 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 
-
 using Vala;
 using GLib;
 using Gee;
 
-
-public interface Valadoc.ConstructionMethodHandler : Basic, MethodHandler {
+public interface Valadoc.ConstructionMethodHandler : Api.Node {
 	public Gee.Collection<Method> get_construction_method_list () {
 		return get_children_by_type (Api.NodeType.CREATION_METHOD);
 	}
@@ -31,21 +29,4 @@ public interface Valadoc.ConstructionMethodHandler : Basic, MethodHandler {
 	public void visit_construction_methods ( Doclet doclet ) {
 		accept_children_by_type (Api.NodeType.CREATION_METHOD, doclet);
 	}
-
-	protected void add_construction_method ( Vala.CreationMethod vm ) {
-		var tmp = new Method ( this.settings, vm, this, this.head );
-		add_child ( tmp );
-	}
-
-	protected void add_methods_and_construction_methods ( Gee.Collection<Vala.Method> vmethods ) {
-		foreach ( Vala.Method vm in vmethods ) {
-			if ( vm is Vala.CreationMethod ) {
-				this.add_construction_method ( (Vala.CreationMethod)vm );
-			}
-			else {
-				this.add_method ( vm );
-			}
-		}
-	}
 }
-
diff --git a/src/libvaladoc/apitree/delegate.vala b/src/libvaladoc/apitree/delegate.vala
index d2a113e..445d526 100644
--- a/src/libvaladoc/apitree/delegate.vala
+++ b/src/libvaladoc/apitree/delegate.vala
@@ -26,16 +26,13 @@ using Gee;
 public class Valadoc.Delegate : Api.TypeSymbolNode, ParameterListHandler, ReturnTypeHandler, TemplateParameterListHandler, ExceptionHandler {
 	private Vala.Delegate vdelegate;
 
-	public Delegate (Valadoc.Settings settings, Vala.Delegate symbol, DelegateHandler parent, Tree root) {
+	public Delegate (Valadoc.Settings settings, Vala.Delegate symbol, Api.Node parent, Tree root) {
 		base (settings, symbol, parent, root);
 
 		this.vdelegate = symbol;
 
 		var ret = this.vdelegate.return_type;
 		this.set_ret_type ( ret );
-
-		var vparamlst = this.vdelegate.get_parameters ();
-		this.add_parameter_list ( vparamlst );
 	}
 
 	public string? get_cname () {
diff --git a/src/libvaladoc/apitree/delegatehandler.vala b/src/libvaladoc/apitree/delegatehandler.vala
index a4ac4f4..abd2306 100644
--- a/src/libvaladoc/apitree/delegatehandler.vala
+++ b/src/libvaladoc/apitree/delegatehandler.vala
@@ -29,15 +29,4 @@ public interface Valadoc.DelegateHandler : Api.Node {
 	public void visit_delegates ( Doclet doclet ) {
 		accept_children_by_type (Api.NodeType.DELEGATE, doclet);
 	}
-
-	public void add_delegates ( Gee.Collection<Vala.Delegate> vdels ) {
-		foreach ( Vala.Delegate vdel in vdels ) {
-			this.add_delegate ( vdel );
-		}
-	}
-
-	public void add_delegate ( Vala.Delegate vdel ) {
-		var tmp = new Delegate ( this.settings, vdel, this, this.head );
-		add_child ( tmp );
-	}
 }
diff --git a/src/libvaladoc/apitree/enum.vala b/src/libvaladoc/apitree/enum.vala
index 563a01c..2d669b7 100644
--- a/src/libvaladoc/apitree/enum.vala
+++ b/src/libvaladoc/apitree/enum.vala
@@ -24,15 +24,9 @@ using Gee;
 
 
 public class Valadoc.Enum : Api.TypeSymbolNode, MethodHandler {
-	public Enum (Valadoc.Settings settings, Vala.Enum symbol, EnumHandler parent, Tree root) {
+	public Enum (Valadoc.Settings settings, Vala.Enum symbol, Api.Node parent, Tree root) {
 		base (settings, symbol, parent, root);
 		this.venum = symbol;
-
-		Gee.Collection<Vala.Method> vmethods = this.venum.get_methods ();
-		this.add_methods ( vmethods );
-
-		Gee.Collection<Vala.EnumValue> venvals = this.venum.get_values ();
-		this.add_enum_values ( venvals );
 	}
 
 	public string? get_cname () {
@@ -44,13 +38,6 @@ public class Valadoc.Enum : Api.TypeSymbolNode, MethodHandler {
 		return get_children_by_type (Api.NodeType.ENUM_VALUE);
 	}
 
-	private inline void add_enum_values ( Gee.Collection<Vala.EnumValue> venvals ) {
-		foreach ( Vala.EnumValue venval in venvals ) {
-			var tmp = new EnumValue ( this.settings, venval, this, this.head );
-			add_child ( tmp );
-		}
-	}
-
 	public void visit_enum_values ( Doclet doclet ) {
 		accept_children_by_type (Api.NodeType.ENUM_VALUE, doclet);
 	}
diff --git a/src/libvaladoc/apitree/enumvalue.vala b/src/libvaladoc/apitree/enumvalue.vala
index fbdded9..ff22634 100644
--- a/src/libvaladoc/apitree/enumvalue.vala
+++ b/src/libvaladoc/apitree/enumvalue.vala
@@ -26,7 +26,7 @@ using Gee;
 public class Valadoc.EnumValue: Api.SymbolNode {
 	private Vala.EnumValue venval;
 
-	public EnumValue (Valadoc.Settings settings, Vala.EnumValue symbol, Enum parent, Tree root) {
+	public EnumValue (Valadoc.Settings settings, Vala.EnumValue symbol, Api.Node parent, Tree root) {
 		base (settings, symbol, parent, root);
 		this.venval = symbol;
 	}
diff --git a/src/libvaladoc/apitree/errorcode.vala b/src/libvaladoc/apitree/errorcode.vala
index a524883..d0fa8a0 100644
--- a/src/libvaladoc/apitree/errorcode.vala
+++ b/src/libvaladoc/apitree/errorcode.vala
@@ -26,7 +26,7 @@ using Gee;
 public class Valadoc.ErrorCode : Api.TypeSymbolNode {
 	private Vala.ErrorCode verrcode;
 
-	public ErrorCode (Valadoc.Settings settings, Vala.ErrorCode symbol, ErrorDomain parent, Tree root) {
+	public ErrorCode (Valadoc.Settings settings, Vala.ErrorCode symbol, Api.Node parent, Tree root) {
 		base (settings, symbol, parent, root);
 		this.verrcode = symbol;
 	}
diff --git a/src/libvaladoc/apitree/errordomain.vala b/src/libvaladoc/apitree/errordomain.vala
index 283de0c..af4fc5b 100644
--- a/src/libvaladoc/apitree/errordomain.vala
+++ b/src/libvaladoc/apitree/errordomain.vala
@@ -17,31 +17,23 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 
-
 using Vala;
 using GLib;
 using Gee;
 
-
 public class Valadoc.ErrorDomain : Api.TypeSymbolNode, MethodHandler {
 	private Vala.ErrorDomain verrdom;
 
-	public ErrorDomain (Valadoc.Settings settings, Vala.ErrorDomain symbol, ErrorDomainHandler parent, Tree root) {
+	public ErrorDomain (Valadoc.Settings settings, Vala.ErrorDomain symbol, Api.Node parent, Tree root) {
 		base (settings, symbol, parent, root);
 		this.verrdom = symbol;
-
-		Gee.Collection<Vala.Method> vmethods = this.verrdom.get_methods ();
-		this.add_methods ( vmethods );
-
-		Gee.Collection<Vala.ErrorCode> verrcodes = this.verrdom.get_codes ();
-		this.append_error_code ( verrcodes );
 	}
 
 	public string? get_cname () {
 		return this.verrdom.get_cname();
 	}
 
-	public void visit_error_codes ( Doclet doclet ) {
+	public void visit_error_codes (Doclet doclet) {
 		accept_children_by_type (Api.NodeType.ERROR_CODE, doclet);
 	}
 
@@ -49,7 +41,7 @@ public class Valadoc.ErrorDomain : Api.TypeSymbolNode, MethodHandler {
 		return get_children_by_type (Api.NodeType.ERROR_CODE);
 	}
 
-	public void visit ( Doclet doclet ) {
+	public void visit (Doclet doclet) {
 		if ( !this.is_visitor_accessible ( ) )
 			return ;
 
@@ -65,12 +57,4 @@ public class Valadoc.ErrorDomain : Api.TypeSymbolNode, MethodHandler {
 	public void write ( Langlet langlet, void* ptr ) {
 		langlet.write_error_domain ( this, ptr );
 	}
-
-	private inline void append_error_code ( Gee.Collection<Vala.ErrorCode> verrcodes ) {
-		foreach ( Vala.ErrorCode verrcode in verrcodes ) {
-			var tmp = new ErrorCode ( this.settings, verrcode, this, this.head );
-			add_child ( tmp );
-		}
-	}
 }
-
diff --git a/src/libvaladoc/apitree/errordomainhandler.vala b/src/libvaladoc/apitree/errordomainhandler.vala
index 168e5e0..cce01bd 100644
--- a/src/libvaladoc/apitree/errordomainhandler.vala
+++ b/src/libvaladoc/apitree/errordomainhandler.vala
@@ -29,15 +29,4 @@ public interface Valadoc.ErrorDomainHandler : Api.Node {
 	public void visit_error_domains (Doclet doclet) {
 		accept_children_by_type (Api.NodeType.ERROR_DOMAIN, doclet);
 	}
-
-	public void add_error_domains (Gee.Collection<Vala.ErrorDomain> verrdoms) {
-		foreach ( Vala.ErrorDomain verrdom in  verrdoms ) {
-			this.add_error_domain ( verrdom );
-		}
-	}
-
-	public void add_error_domain ( Vala.ErrorDomain verrdom ) {
-		var tmp = new ErrorDomain ( this.settings, verrdom, this, this.head );
-		add_child ( tmp );
-	}
 }
diff --git a/src/libvaladoc/apitree/field.vala b/src/libvaladoc/apitree/field.vala
index 646fc7e..cdfaf29 100644
--- a/src/libvaladoc/apitree/field.vala
+++ b/src/libvaladoc/apitree/field.vala
@@ -26,7 +26,7 @@ using Gee;
 public class Valadoc.Field : Api.MemberNode, ReturnTypeHandler {
 	private Vala.Field vfield;
 
-	public Field (Valadoc.Settings settings, Vala.Field symbol, FieldHandler parent, Tree root) {
+	public Field (Valadoc.Settings settings, Vala.Field symbol, Api.Node parent, Tree root) {
 		base (settings, symbol, parent, root);
 		this.vfield = symbol;
 
diff --git a/src/libvaladoc/apitree/fieldhandler.vala b/src/libvaladoc/apitree/fieldhandler.vala
index 0b867bb..37605f8 100644
--- a/src/libvaladoc/apitree/fieldhandler.vala
+++ b/src/libvaladoc/apitree/fieldhandler.vala
@@ -22,22 +22,11 @@ using GLib;
 using Gee;
 
 public interface Valadoc.FieldHandler : Api.Node {
-	public Gee.Collection<Field> get_field_list ( ) {
+	public Gee.Collection<Field> get_field_list () {
 		return get_children_by_type (Api.NodeType.FIELD);
 	}
 
-	internal void add_fields ( Gee.Collection<Vala.Field> vfields ) {
-		foreach ( Vala.Field vf in vfields ) {
-			this.add_field ( vf );
-		}
-	}
-
-	internal void add_field ( Vala.Field vf ) {
-		var tmp = new Field ( this.settings, vf, this, this.head );
-		add_child ( tmp );
-	}
-
-	public void visit_fields ( Doclet doclet ) {
+	public void visit_fields (Doclet doclet) {
 		accept_children_by_type (Api.NodeType.FIELD, doclet);
 	}
 }
diff --git a/src/libvaladoc/apitree/formalparameter.vala b/src/libvaladoc/apitree/formalparameter.vala
index 4887a1c..4ac9d83 100644
--- a/src/libvaladoc/apitree/formalparameter.vala
+++ b/src/libvaladoc/apitree/formalparameter.vala
@@ -24,7 +24,7 @@ using Gee;
 public class Valadoc.FormalParameter : Api.SymbolNode, ReturnTypeHandler {
 	private Vala.FormalParameter vformalparam;
 
-	public FormalParameter (Valadoc.Settings settings, Vala.FormalParameter symbol, ParameterListHandler parent, Tree root) {
+	public FormalParameter (Valadoc.Settings settings, Vala.FormalParameter symbol, Api.Node parent, Tree root) {
 		base (settings, symbol, parent, root);
 		this.vformalparam = symbol;
 
diff --git a/src/libvaladoc/apitree/interface.vala b/src/libvaladoc/apitree/interface.vala
index f078674..43f90a8 100644
--- a/src/libvaladoc/apitree/interface.vala
+++ b/src/libvaladoc/apitree/interface.vala
@@ -24,39 +24,9 @@ using Gee;
 
 
 public class Valadoc.Interface : Api.TypeSymbolNode, SignalHandler, PropertyHandler, FieldHandler, ConstantHandler, TemplateParameterListHandler, MethodHandler, DelegateHandler, EnumHandler, StructHandler, ClassHandler {
-	public Interface (Valadoc.Settings settings, Vala.Interface symbol, InterfaceHandler parent, Tree root) {
+	public Interface (Valadoc.Settings settings, Vala.Interface symbol, Api.Node parent, Tree root) {
 		base (settings, symbol, parent, root);
 		this.vinterface = symbol;
-
-		var vtparams = this.vinterface.get_type_parameters ();
-		this.set_template_parameter_list (vtparams);
-
-		Gee.Collection<Vala.Method> methods = this.vinterface.get_methods ();
-		this.add_methods (methods);
-
-		Gee.Collection<Vala.Delegate> delegates = this.vinterface.get_delegates ();
-		this.add_delegates (delegates);
-
-		Gee.Collection<Vala.Signal> signals = this.vinterface.get_signals();
-		this.add_signals (signals);
-
-		Gee.Collection<Vala.Property> properties = this.vinterface.get_properties();
-		this.add_properties (properties);
-
-		Gee.Collection<Vala.Field> fields = this.vinterface.get_fields();
-		this.add_fields (fields);
-
-		Gee.Collection<Vala.Struct> structs = this.vinterface.get_structs();
-		this.add_structs (structs);
-
-		Gee.Collection<Vala.Class> classes = this.vinterface.get_classes();
-		this.add_classes (classes);
-
-		Gee.Collection<Vala.Enum> enums = this.vinterface.get_enums();
-		this.add_enums (enums);
-
-		Gee.Collection<Vala.Constant> constants = this.vinterface.get_constants();
-		this.add_constants ( constants );
 	}
 
 	private Gee.ArrayList<Interface> interfaces = new Gee.ArrayList<Interface>();
diff --git a/src/libvaladoc/apitree/interfacehandler.vala b/src/libvaladoc/apitree/interfacehandler.vala
index c2c1455..8e69095 100644
--- a/src/libvaladoc/apitree/interfacehandler.vala
+++ b/src/libvaladoc/apitree/interfacehandler.vala
@@ -22,22 +22,11 @@ using GLib;
 using Gee;
 
 public interface Valadoc.InterfaceHandler : Api.Node {
-	public Gee.Collection<Interface> get_interface_list ( ) {
+	public Gee.Collection<Interface> get_interface_list () {
 		return get_children_by_type (Api.NodeType.INTERFACE);
 	}
 
-	public void visit_interfaces ( Doclet doclet ) {
+	public void visit_interfaces (Doclet doclet) {
 		accept_children_by_type (Api.NodeType.INTERFACE, doclet);
 	}
-
-	protected void add_interfaces ( Gee.Collection<Vala.Interface> vifaces ) {
-		foreach ( Vala.Interface viface in vifaces ) {
-			this.add_interface ( viface );
-		}
-	}
-
-	internal void add_interface ( Vala.Interface viface ) {
-		var tmp = new Interface ( this.settings, viface, this, this.head );
-		add_child (tmp);
-	}
 }
diff --git a/src/libvaladoc/apitree/method.vala b/src/libvaladoc/apitree/method.vala
index 1367aba..2845c04 100644
--- a/src/libvaladoc/apitree/method.vala
+++ b/src/libvaladoc/apitree/method.vala
@@ -26,18 +26,12 @@ using Gee;
 public class Valadoc.Method : Api.MemberNode, ParameterListHandler, ExceptionHandler, TemplateParameterListHandler, ReturnTypeHandler {
 	private Vala.Method vmethod;
 
-	public Method (Valadoc.Settings settings, Vala.Method symbol, MethodHandler parent, Tree root) {
+	public Method (Valadoc.Settings settings, Vala.Method symbol, Api.Node parent, Tree root) {
 		base (settings, symbol, parent, root);
 		this.vmethod = symbol;
 
 		var vret = this.vmethod.return_type;
 		this.set_ret_type (vret);
-
-		var vparamlst = this.vmethod.get_parameters ();
-		this.add_parameter_list (vparamlst);
-
-		var vtparams = this.vmethod.get_type_parameters ();
-		this.set_template_parameter_list (vtparams);
 	}
 
 	public string? get_cname () {
diff --git a/src/libvaladoc/apitree/methodhandler.vala b/src/libvaladoc/apitree/methodhandler.vala
index 20e1b75..b4d9a83 100644
--- a/src/libvaladoc/apitree/methodhandler.vala
+++ b/src/libvaladoc/apitree/methodhandler.vala
@@ -22,22 +22,11 @@ using GLib;
 using Gee;
 
 public interface Valadoc.MethodHandler : Api.Node {
-	protected void add_method ( Vala.Method vmethod ) {
-		var tmp = new Method ( this.settings, vmethod, this, this.head );
-		add_child ( tmp );
-	}
-
-	protected void add_methods ( Gee.Collection<Vala.Method> vmethods ) {
-		foreach ( Vala.Method vm in vmethods ) {
-			this.add_method ( vm );
-		}
-	}
-
-	public void visit_methods ( Doclet doclet ) {
+	public void visit_methods (Doclet doclet) {
 		accept_children_by_type (Api.NodeType.METHOD, doclet);
 	}
 
-	public Gee.Collection<Method> get_method_list ( ) {
+	public Gee.Collection<Method> get_method_list () {
 		return get_children_by_type (Api.NodeType.METHOD);
 	}
 }
diff --git a/src/libvaladoc/apitree/package.vala b/src/libvaladoc/apitree/package.vala
index ad80b5b..088ebce 100644
--- a/src/libvaladoc/apitree/package.vala
+++ b/src/libvaladoc/apitree/package.vala
@@ -107,10 +107,15 @@ public class Valadoc.Package : Api.Node, NamespaceHandler {
 		}
 	}
 
+	// TODO Remove
 	internal bool is_vpackage (Vala.SourceFile vfile) {
 		return this.vfiles.contains (vfile);
 	}
 
+	internal bool is_package_for_file (Vala.SourceFile source_file) {
+		return this.vfiles.contains (source_file);
+	}
+
 	protected override bool is_type_visitor_accessible (Valadoc.Basic element) {
 		return true;
 	}
diff --git a/src/libvaladoc/apitree/parameterlisthandler.vala b/src/libvaladoc/apitree/parameterlisthandler.vala
index 10ff9c4..4a6263f 100644
--- a/src/libvaladoc/apitree/parameterlisthandler.vala
+++ b/src/libvaladoc/apitree/parameterlisthandler.vala
@@ -30,11 +30,4 @@ public interface Valadoc.ParameterListHandler : Api.Node {
 	public Gee.List<FormalParameter> get_parameter_list () {
 		return (Gee.List<FormalParameter>) get_children_by_type (Api.NodeType.FORMAL_PARAMETER);
 	}
-
-	protected void add_parameter_list (Gee.Collection<Vala.FormalParameter> vparams) {
-		foreach (Vala.FormalParameter vfparam in vparams) {
-			var tmp = new FormalParameter (this.settings, vfparam, this, this.head);
-			add_child (tmp);
-		}
-	}
 }
diff --git a/src/libvaladoc/apitree/property.vala b/src/libvaladoc/apitree/property.vala
index 0817a2c..01eacc6 100644
--- a/src/libvaladoc/apitree/property.vala
+++ b/src/libvaladoc/apitree/property.vala
@@ -26,7 +26,7 @@ using Gee;
 public class Valadoc.Property : Api.MemberNode, ReturnTypeHandler {
 	private Vala.Property vproperty;
 
-	public Property (Valadoc.Settings settings, Vala.Property symbol, PropertyHandler parent, Tree root) {
+	public Property (Valadoc.Settings settings, Vala.Property symbol, Api.Node parent, Tree root) {
 		base (settings, symbol, parent, root);
 
 		this.vproperty = symbol;
diff --git a/src/libvaladoc/apitree/propertyhandler.vala b/src/libvaladoc/apitree/propertyhandler.vala
index 3b7fa2c..04bfd67 100644
--- a/src/libvaladoc/apitree/propertyhandler.vala
+++ b/src/libvaladoc/apitree/propertyhandler.vala
@@ -22,32 +22,25 @@ using GLib;
 using Gee;
 
 public interface Valadoc.PropertyHandler : Api.Node {
-	protected bool is_overwritten_property ( Property prop ) {
-		foreach ( Property p in get_property_list () ) {
-			if ( p.parent != this )
+	protected bool is_overwritten_property (Property prop) {
+		foreach (Property p in get_property_list ()) {
+			if (p.parent != this)
 				continue ;
 
-			if ( !p.is_override )
+			if (!p.is_override)
 				continue ;
 
-			if ( p.equals ( prop ) )
+			if (p.equals (prop))
 				return true;
 		}
 		return false;
 	}
 
-	public Gee.Collection<Property> get_property_list ( ) {
+	public Gee.Collection<Property> get_property_list () {
 		return get_children_by_type (Api.NodeType.PROPERTY);
 	}
 
-	public void visit_properties ( Doclet doclet ) {
+	public void visit_properties (Doclet doclet) {
 		accept_children_by_type (Api.NodeType.PROPERTY, doclet);
 	}
-
-	protected void add_properties ( Gee.Collection<Vala.Property> vproperties ) {
-		foreach ( Vala.Property vprop in vproperties ) {
-			var tmp = new Property ( this.settings, vprop, this, this.head );
-			add_child ( tmp );
-		}
-	}
 }
diff --git a/src/libvaladoc/apitree/signal.vala b/src/libvaladoc/apitree/signal.vala
index 2af364d..c59d8c1 100644
--- a/src/libvaladoc/apitree/signal.vala
+++ b/src/libvaladoc/apitree/signal.vala
@@ -26,15 +26,11 @@ using Gee;
 public class Valadoc.Signal : Api.MemberNode, ParameterListHandler, ReturnTypeHandler {
 	private Vala.Signal vsignal;
 
-	public Signal (Valadoc.Settings settings, Vala.Signal symbol, SignalHandler parent, Tree root) {
+	public Signal (Valadoc.Settings settings, Vala.Signal symbol, Api.Node parent, Tree root) {
 		base (settings, symbol, parent, root);
 
 		this.vsignal = symbol;
 
-		this.param_list = new Gee.ArrayList<FormalParameter> ();
-		var vparamlst = this.vsignal.get_parameters ();
-		this.add_parameter_list (vparamlst);
-
 		var ret = this.vsignal.return_type;
 		this.set_ret_type (ret);
 	}
@@ -48,11 +44,6 @@ public class Valadoc.Signal : Api.MemberNode, ParameterListHandler, ReturnTypeHa
 		get;
 	}
 
-	protected Gee.ArrayList<FormalParameter> param_list {
-		protected set;
-		get;
-	}
-
 	protected override void resolve_type_references () {
 		this.set_return_type_references ( );
 
diff --git a/src/libvaladoc/apitree/signalhandler.vala b/src/libvaladoc/apitree/signalhandler.vala
index 834b06c..464f94a 100644
--- a/src/libvaladoc/apitree/signalhandler.vala
+++ b/src/libvaladoc/apitree/signalhandler.vala
@@ -22,14 +22,7 @@ using GLib;
 using Gee;
 
 public interface Valadoc.SignalHandler : Api.Node {
-	internal void add_signals ( Gee.Collection<Vala.Signal> vsignals ) {
-		foreach ( Vala.Signal vsig in vsignals ) {
-			var tmp = new Signal ( this.settings, vsig, this, this.head );
-			add_child ( tmp );
-		}
-	}
-
-	public void visit_signals ( Doclet doclet ) {
+	public void visit_signals (Doclet doclet) {
 		accept_children_by_type (Api.NodeType.SIGNAL, doclet);
 	}
 
diff --git a/src/libvaladoc/apitree/struct.vala b/src/libvaladoc/apitree/struct.vala
index b84ed98..f5c4b75 100644
--- a/src/libvaladoc/apitree/struct.vala
+++ b/src/libvaladoc/apitree/struct.vala
@@ -26,21 +26,9 @@ using Gee;
 public class Valadoc.Struct : Api.TypeSymbolNode, MethodHandler, ConstructionMethodHandler, FieldHandler, ConstantHandler, TemplateParameterListHandler {
 	private Vala.Struct vstruct;
 
-	public Struct (Valadoc.Settings settings, Vala.Struct symbol, StructHandler parent, Tree root) {
+	public Struct (Valadoc.Settings settings, Vala.Struct symbol, Api.Node parent, Tree root) {
 		base (settings, symbol, parent, root);
 		this.vstruct = symbol;
-
-		var vtparams = this.vstruct.get_type_parameters ();
-		this.set_template_parameter_list (vtparams);
-
-		Gee.Collection<Vala.Field> vfields = this.vstruct.get_fields();
-		this.add_fields (vfields);
-
-		Gee.Collection<Vala.Constant> vconstants = this.vstruct.get_constants();
-		this.add_constants (vconstants);
-
-		Gee.Collection<Vala.Method> vmethods = this.vstruct.get_methods ();
-		this.add_methods_and_construction_methods (vmethods);
 	}
 
 	protected Struct? base_type {
diff --git a/src/libvaladoc/apitree/structhandler.vala b/src/libvaladoc/apitree/structhandler.vala
index dbc49e0..64784d1 100644
--- a/src/libvaladoc/apitree/structhandler.vala
+++ b/src/libvaladoc/apitree/structhandler.vala
@@ -22,22 +22,11 @@ using GLib;
 using Gee;
 
 public interface Valadoc.StructHandler : Api.Node {
-	public Gee.Collection<Struct> get_struct_list ( ) {
+	public Gee.Collection<Struct> get_struct_list () {
 		return get_children_by_type (Api.NodeType.STRUCT);
 	}
 
-	public void add_struct ( Vala.Struct vstru ) {
-		Struct stru = new Struct ( this.settings, vstru, this, this.head );
-		add_child (stru);
-	}
-
-	public void add_structs ( Gee.Collection<Vala.Struct> vstructs ) {
-		foreach ( Vala.Struct vstru in vstructs ) {
-			this.add_struct ( vstru );
-		}
-	}
-
-	public void visit_structs ( Doclet doclet ) {
+	public void visit_structs (Doclet doclet) {
 		accept_children_by_type (Api.NodeType.STRUCT, doclet);
 	}
 }
diff --git a/src/libvaladoc/apitree/templateparameterlisthandler.vala b/src/libvaladoc/apitree/templateparameterlisthandler.vala
index 6c2a490..c1d20db 100644
--- a/src/libvaladoc/apitree/templateparameterlisthandler.vala
+++ b/src/libvaladoc/apitree/templateparameterlisthandler.vala
@@ -25,11 +25,4 @@ public interface Valadoc.TemplateParameterListHandler : Api.Node {
 	public Gee.Collection<TypeParameter> get_template_param_list () {
 		return get_children_by_type (Api.NodeType.TYPE_PARAMETER);
 	}
-
-	internal void set_template_parameter_list (Gee.Collection<Vala.TypeParameter> vtparams) {
-		foreach ( Vala.TypeParameter vtparam in vtparams ) {
-			var tmp = new TypeParameter (this.settings, vtparam, this, this.head);
-			add_child (tmp);
-		}
-	}
 }
diff --git a/src/libvaladoc/apitree/typeparameter.vala b/src/libvaladoc/apitree/typeparameter.vala
index b4da003..67116c6 100644
--- a/src/libvaladoc/apitree/typeparameter.vala
+++ b/src/libvaladoc/apitree/typeparameter.vala
@@ -25,7 +25,7 @@ using Gee;
 
 public class Valadoc.TypeParameter : Api.SymbolNode, ReturnTypeHandler {
 
-	public TypeParameter (Valadoc.Settings settings, Vala.TypeParameter symbol, TemplateParameterListHandler parent, Tree root) {
+	public TypeParameter (Valadoc.Settings settings, Vala.TypeParameter symbol, Api.Node parent, Tree root) {
 		base (settings, symbol, parent, root);
 	}
 



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