From: Didier 'Ptitjes Date: Wed, 14 Oct 2009 12:27:31 +0000 (+0200) Subject: Api: Externalize nodes creation X-Git-Tag: 0.37.1~3^2~570 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0d72f4e305cf97161b4c9bd1aafa6932a3aebfda;p=thirdparty%2Fvala.git Api: Externalize nodes creation --- diff --git a/src/libvaladoc/Makefile.am b/src/libvaladoc/Makefile.am index 151fe5a49..58471d87d 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 000000000..5355fa1ca --- /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 + */ + +using Vala; +using Gee; + +internal class Valadoc.Api.NodeBuilder : CodeVisitor { + private Settings settings; + private Tree root; + private Gee.Collection 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 c48d9d2dc..bf349a684 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 packages = new Gee.ArrayList(); 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 3ca2f57be..5119c6cde 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 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(); @@ -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 venums = this.vclass.get_enums (); - this.add_enums ( venums ); - - Gee.Collection vdelegates = this.vclass.get_delegates (); - this.add_delegates ( vdelegates ); - - Gee.Collection vclasses = this.vclass.get_classes(); - this.add_classes ( vclasses ); - - Gee.Collection vstructs = this.vclass.get_structs(); - this.add_structs ( vstructs ); - - Gee.Collection vfields = this.vclass.get_fields(); - this.add_fields ( vfields ); - - Gee.Collection vmethods = this.vclass.get_methods (); - this.add_methods_and_construction_methods ( vmethods ); - - Gee.Collection vsignals = this.vclass.get_signals(); - this.add_signals ( vsignals ); - - Gee.Collection vproperties = this.vclass.get_properties(); - this.add_properties ( vproperties ); - - Gee.Collection 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 fef2f9dcd..ed3837830 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 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 eb667f139..cf6f873e3 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 fc11201ba..c9a152beb 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 get_constant_list ( ) { + public Gee.Collection get_constant_list () { return get_children_by_type (Api.NodeType.CONSTANT); } - internal void add_constants (Gee.Collection 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 b1d5c1038..d54e111cd 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 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 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 d2a113e01..445d526ec 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 a4ac4f443..abd2306e4 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 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 563a01ca7..2d669b74d 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 vmethods = this.venum.get_methods (); - this.add_methods ( vmethods ); - - Gee.Collection 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 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 fbdded94e..ff2263447 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 a52488330..d0fa8a0b5 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 283de0c75..af4fc5b6a 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 vmethods = this.verrdom.get_methods (); - this.add_methods ( vmethods ); - - Gee.Collection 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 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 168e5e043..cce01bddb 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 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 646fc7e5d..cdfaf2961 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 0b867bb25..37605f825 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 get_field_list ( ) { + public Gee.Collection get_field_list () { return get_children_by_type (Api.NodeType.FIELD); } - internal void add_fields ( Gee.Collection 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 4887a1c5c..4ac9d8371 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 f078674e1..43f90a8ea 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 methods = this.vinterface.get_methods (); - this.add_methods (methods); - - Gee.Collection delegates = this.vinterface.get_delegates (); - this.add_delegates (delegates); - - Gee.Collection signals = this.vinterface.get_signals(); - this.add_signals (signals); - - Gee.Collection properties = this.vinterface.get_properties(); - this.add_properties (properties); - - Gee.Collection fields = this.vinterface.get_fields(); - this.add_fields (fields); - - Gee.Collection structs = this.vinterface.get_structs(); - this.add_structs (structs); - - Gee.Collection classes = this.vinterface.get_classes(); - this.add_classes (classes); - - Gee.Collection enums = this.vinterface.get_enums(); - this.add_enums (enums); - - Gee.Collection constants = this.vinterface.get_constants(); - this.add_constants ( constants ); } private Gee.ArrayList interfaces = new Gee.ArrayList(); diff --git a/src/libvaladoc/apitree/interfacehandler.vala b/src/libvaladoc/apitree/interfacehandler.vala index c2c1455d3..8e69095fa 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 get_interface_list ( ) { + public Gee.Collection 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 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 1367aba6c..2845c042d 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 20e1b75b3..b4d9a836a 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 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 get_method_list ( ) { + public Gee.Collection 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 ad80b5b52..088ebcec5 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 10ff9c40e..4a6263f79 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 get_parameter_list () { return (Gee.List) get_children_by_type (Api.NodeType.FORMAL_PARAMETER); } - - protected void add_parameter_list (Gee.Collection 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 0817a2c83..01eacc685 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 3b7fa2c0a..04bfd675d 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 get_property_list ( ) { + public Gee.Collection 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 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 2af364d4a..c59d8c1c9 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 (); - 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 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 834b06cca..464f94a62 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 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 b84ed9816..f5c4b7511 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 vfields = this.vstruct.get_fields(); - this.add_fields (vfields); - - Gee.Collection vconstants = this.vstruct.get_constants(); - this.add_constants (vconstants); - - Gee.Collection 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 dbc49e02e..64784d1d4 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 get_struct_list ( ) { + public Gee.Collection 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 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 6c2a490b8..c1d20db0f 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 get_template_param_list () { return get_children_by_type (Api.NodeType.TYPE_PARAMETER); } - - internal void set_template_parameter_list (Gee.Collection 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 b4da0033a..67116c615 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); }