From: Didier "Ptitjes Date: Tue, 20 Oct 2009 00:48:26 +0000 (+0200) Subject: Api: Remove *Handler interfaces X-Git-Tag: 0.37.1~3^2~545 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=060d4fcb9e2108ff71ded5ea572eaf70352e0d27;p=thirdparty%2Fvala.git Api: Remove *Handler interfaces --- diff --git a/src/doclets/devhelp/doclet/doclet.vala b/src/doclets/devhelp/doclet/doclet.vala index b0415ac90..3a4714b9a 100755 --- a/src/doclets/devhelp/doclet/doclet.vala +++ b/src/doclets/devhelp/doclet/doclet.vala @@ -222,10 +222,11 @@ public class Valadoc.Devhelp.Doclet : Valadoc.Html.BasicDoclet { write_wiki_pages ( tree, css_path_wiki, Path.build_filename(this.settings.path, this.settings.pkg_name, "content") ); - Gee.Collection packages = tree.get_package_list (); - foreach ( Package pkg in packages ) { - pkg.accept (this); - } + tree.accept (this); + } + + public override void visit_tree (Api.Tree tree) { + tree.accept_children (this); } public override void visit_package (Package package) { @@ -257,278 +258,111 @@ public class Valadoc.Devhelp.Doclet : Valadoc.Html.BasicDoclet { write_file_footer (); file = null; - package.visit_namespaces ( this ); + package.accept_all_children (this); this.devhelp.save_file ( devpath ); } - public override void visit_namespace ( Namespace ns ) { - if ( ns.name != null ) { - string rpath = this.get_real_path ( ns ); - string path = this.get_path ( ns ); + private void process_compound_node (Api.Node node, KeywordType type) { + string rpath = this.get_real_path (node); + string path = this.get_path (node); - GLib.FileStream file = GLib.FileStream.open ( rpath, "w" ); + if (node.name != null) { + this.devhelp.add_chapter_start (node.name, path); + + GLib.FileStream file = GLib.FileStream.open (rpath, "w"); writer = new MarkupWriter (file); _renderer.set_writer (writer); - write_file_header (this.css_path, ns.full_name()); - write_namespace_content (ns, ns); + write_file_header (css_path, node.full_name()); + write_symbol_content (node); write_file_footer (); file = null; - - this.devhelp.add_keyword ( KeywordType.NAMESPACE, ns.name, path ); - this.devhelp.add_chapter_start ( ns.name, path ); } - ns.visit_namespaces ( this ); - ns.visit_classes ( this ); - ns.visit_interfaces ( this ); - ns.visit_structs ( this ); - ns.visit_enums ( this ); - ns.visit_error_domains ( this ); - ns.visit_delegates ( this ); - ns.visit_methods ( this ); - ns.visit_fields ( this ); - ns.visit_constants ( this ); - - if ( ns.name != null ) { - this.devhelp.add_chapter_end ( ); + node.accept_all_children (this); + + if (node.name != null) { + this.devhelp.add_chapter_end (); + this.devhelp.add_keyword (type, node.name, path); } } - public override void visit_interface ( Interface iface ) { - string rpath = this.get_real_path ( iface ); - string path = this.get_path ( iface ); - + private void process_node (Api.Node node, KeywordType type) { + string rpath = this.get_real_path (node); + string path = this.get_path (node); - this.devhelp.add_chapter_start ( iface.name, path ); - - iface.visit_classes ( this ); - iface.visit_structs ( this ); - iface.visit_enums ( this ); - iface.visit_delegates ( this ); - iface.visit_methods ( this ); - iface.visit_signals ( this ); - iface.visit_properties ( this ); - iface.visit_fields ( this ); - iface.visit_constants ( this ); - - this.devhelp.add_chapter_end ( ); - - this.devhelp.add_keyword ( KeywordType.INTERFACE, iface.name, path ); - - GLib.FileStream file = GLib.FileStream.open ( rpath, "w"); + GLib.FileStream file = GLib.FileStream.open (rpath, "w"); writer = new MarkupWriter (file); _renderer.set_writer (writer); - write_file_header (this.css_path, iface.full_name()); - write_symbol_content (iface); + write_file_header (css_path, node.full_name()); + write_symbol_content (node); write_file_footer (); file = null; - } - public override void visit_class ( Class cl ) { - string rpath = this.get_real_path ( cl ); - string path = this.get_path ( cl ); + node.accept_all_children (this); - - this.devhelp.add_keyword ( KeywordType.CLASS, cl.name, path ); - this.devhelp.add_chapter_start ( cl.name, path ); - - cl.visit_construction_methods ( this ); - cl.visit_classes ( this ); - cl.visit_structs ( this ); - cl.visit_enums ( this ); - cl.visit_delegates ( this ); - cl.visit_methods ( this ); - cl.visit_signals ( this ); - cl.visit_properties ( this ); - cl.visit_fields ( this ); - cl.visit_constants ( this ); - - this.devhelp.add_chapter_end ( ); - - - GLib.FileStream file = GLib.FileStream.open ( rpath, "w"); - writer = new MarkupWriter (file); - _renderer.set_writer (writer); - write_file_header (this.css_path, cl.full_name()); - write_symbol_content (cl); - write_file_footer (); - file = null; + this.devhelp.add_keyword (type, node.name, path); + this.devhelp.add_chapter (node.name, path); } - public override void visit_struct ( Struct stru ) { - string rpath = this.get_real_path ( stru ); - string path = this.get_path ( stru ); - - - this.devhelp.add_keyword ( KeywordType.STRUCT, stru.name, path ); - this.devhelp.add_chapter_start ( stru.name, path ); - - stru.visit_construction_methods ( this ); - stru.visit_methods ( this ); - stru.visit_fields ( this ); - stru.visit_constants ( this ); - - this.devhelp.add_chapter_end ( ); - - - GLib.FileStream file = GLib.FileStream.open ( rpath, "w"); - writer = new MarkupWriter (file); - _renderer.set_writer (writer); - write_file_header (this.css_path, stru.full_name()); - write_symbol_content (stru); - write_file_footer (); - file = null; + public override void visit_namespace (Namespace item) { + process_compound_node (item, KeywordType.NAMESPACE); } - public override void visit_error_domain ( ErrorDomain errdom ) { - string rpath = this.get_real_path ( errdom ); - string path = this.get_path ( errdom ); - - errdom.visit_methods ( this ); - - this.devhelp.add_keyword ( KeywordType.ERRORDOMAIN, errdom.name, path ); - this.devhelp.add_chapter ( errdom.name, path ); - - GLib.FileStream file = GLib.FileStream.open ( rpath, "w"); - writer = new MarkupWriter (file); - _renderer.set_writer (writer); - write_file_header (this.css_path, errdom.full_name()); - write_symbol_content (errdom); - write_file_footer (); - file = null; + public override void visit_interface (Interface item) { + process_compound_node (item, KeywordType.INTERFACE); } - public override void visit_enum ( Enum en ) { - string rpath = this.get_real_path ( en ); - string path = this.get_path ( en ); - - en.visit_enum_values ( this ); - en.visit_methods ( this ); - - this.devhelp.add_keyword ( KeywordType.ENUM, en.name, path ); - this.devhelp.add_chapter ( en.name, path ); - - GLib.FileStream file = GLib.FileStream.open ( rpath, "w"); - writer = new MarkupWriter (file); - _renderer.set_writer (writer); - write_file_header (this.css_path, en.full_name()); - write_symbol_content (en); - write_file_footer (); - file = null; + public override void visit_class (Class item) { + process_compound_node (item, KeywordType.CLASS); } - public override void visit_property ( Property prop ) { - string rpath = this.get_real_path ( prop ); - string path = this.get_path ( prop ); - - this.devhelp.add_keyword ( KeywordType.PROPERTY, prop.name, path ); - this.devhelp.add_chapter ( prop.name, path ); - - GLib.FileStream file = GLib.FileStream.open ( rpath, "w"); - writer = new MarkupWriter (file); - _renderer.set_writer (writer); - write_file_header (this.css_path, prop.full_name()); - write_symbol_content (prop); - write_file_footer (); - file = null; + public override void visit_struct (Struct item) { + process_compound_node (item, KeywordType.STRUCT); } - public override void visit_constant (Constant constant) { - string rpath = this.get_real_path ( constant ); - string path = this.get_path ( constant ); - - this.devhelp.add_keyword ( KeywordType.VARIABLE, constant.name, path ); - this.devhelp.add_chapter ( constant.name, path ); - - GLib.FileStream file = GLib.FileStream.open ( rpath, "w"); - writer = new MarkupWriter (file); - _renderer.set_writer (writer); - write_file_header (this.css_path, constant.full_name()); - write_symbol_content (constant); - write_file_footer (); - file = null; + public override void visit_error_domain (ErrorDomain item) { + process_node (item, KeywordType.ERRORDOMAIN); } - public override void visit_field (Field field) { - string rpath = this.get_real_path ( field ); - string path = this.get_path ( field ); - - this.devhelp.add_keyword ( KeywordType.VARIABLE, field.name, path ); - this.devhelp.add_chapter ( field.name, path ); - - GLib.FileStream file = GLib.FileStream.open ( rpath, "w"); - writer = new MarkupWriter (file); - _renderer.set_writer (writer); - write_file_header (this.css_path, field.full_name()); - write_symbol_content (field); - write_file_footer (); - file = null; + public override void visit_enum ( Enum item) { + process_node (item, KeywordType.ENUM); } - public override void visit_error_code ( ErrorCode errcode ) { + public override void visit_property (Property item) { + process_node (item, KeywordType.PROPERTY); } - public override void visit_enum_value ( Api.EnumValue enval ) { + public override void visit_constant (Constant item) { + process_node (item, KeywordType.VARIABLE); } - public override void visit_delegate ( Delegate del ) { - string rpath = this.get_real_path ( del ); - string path = this.get_path ( del ); - - this.devhelp.add_keyword ( KeywordType.DELEGATE, del.name, path ); - this.devhelp.add_chapter ( del.name, path ); - - GLib.FileStream file = GLib.FileStream.open ( rpath, "w"); - writer = new MarkupWriter (file); - _renderer.set_writer (writer); - write_file_header (this.css_path, del.full_name()); - write_symbol_content (del); - write_file_footer (); - file = null; + public override void visit_field (Field item) { + process_node (item, KeywordType.VARIABLE); } - public override void visit_signal ( Api.Signal sig ) { - string rpath = this.get_real_path ( sig ); - string path = this.get_path ( sig ); - - this.devhelp.add_keyword ( KeywordType.SIGNAL, sig.name, path ); - this.devhelp.add_chapter ( sig.name, path ); + public override void visit_error_code (ErrorCode item) { + } - GLib.FileStream file = GLib.FileStream.open ( rpath, "w"); - writer = new MarkupWriter (file); - _renderer.set_writer (writer); - write_file_header (this.css_path, sig.full_name()); - write_symbol_content (sig); - write_file_footer (); - file = null; + public override void visit_enum_value (Api.EnumValue item) { } - public override void visit_method (Method m) { - string rpath = this.get_real_path ( m ); - string path = this.get_path ( m ); + public override void visit_delegate (Delegate item) { + process_node (item, KeywordType.DELEGATE); + } - this.devhelp.add_keyword ( KeywordType.FUNCTION, m.name, path ); - this.devhelp.add_chapter ( m.name, path ); + public override void visit_signal (Api.Signal item) { + process_node (item, KeywordType.SIGNAL); + } - GLib.FileStream file = GLib.FileStream.open ( rpath, "w"); - writer = new MarkupWriter (file); - _renderer.set_writer (writer); - write_file_header (this.css_path, m.full_name()); - write_symbol_content (m); - write_file_footer (); - file = null; + public override void visit_method (Method item) { + process_node (item, KeywordType.FUNCTION); } } - - - - [ModuleInit] public Type register_plugin ( ) { Valadoc.Html.get_html_link_imp = Valadoc.Devhelp.get_html_link; return typeof ( Valadoc.Devhelp.Doclet ); } - diff --git a/src/doclets/htm/doclet/doclet.vala b/src/doclets/htm/doclet/doclet.vala index 6d7fbfc39..d6e252c9b 100755 --- a/src/doclets/htm/doclet/doclet.vala +++ b/src/doclets/htm/doclet/doclet.vala @@ -130,10 +130,11 @@ public class Valadoc.HtmlDoclet : Valadoc.Html.BasicDoclet { write_file_footer (); file = null; - Gee.Collection packages = tree.get_package_list (); - foreach ( Package pkg in packages ) { - pkg.accept (this); - } + tree.accept (this); + } + + public override void visit_tree (Api.Tree tree) { + tree.accept_children (this); } public override void visit_package (Package package) { @@ -152,7 +153,7 @@ public class Valadoc.HtmlDoclet : Valadoc.Html.BasicDoclet { write_file_footer (); file = null; - package.visit_namespaces ( this ); + package.accept_all_children (this); } public override void visit_namespace ( Namespace ns ) { @@ -169,208 +170,90 @@ public class Valadoc.HtmlDoclet : Valadoc.Html.BasicDoclet { file = null; } - // file: - ns.visit_namespaces ( this ); - ns.visit_classes ( this ); - ns.visit_interfaces ( this ); - ns.visit_structs ( this ); - ns.visit_enums ( this ); - ns.visit_error_domains ( this ); - ns.visit_delegates ( this ); - ns.visit_methods ( this ); - ns.visit_fields ( this ); - ns.visit_constants ( this ); + ns.accept_all_children (this); } - public override void visit_interface ( Interface iface ) { - string rpath = this.get_real_path ( iface ); - - iface.visit_classes ( this ); - iface.visit_structs ( this ); - iface.visit_enums ( this ); - iface.visit_delegates ( this ); - iface.visit_methods ( this ); - iface.visit_signals ( this ); - iface.visit_properties ( this ); - iface.visit_fields ( this ); - iface.visit_constants ( this ); + private void process_node (Api.Node node) { + string rpath = this.get_real_path (node); - GLib.FileStream file = GLib.FileStream.open ( rpath, "w"); + GLib.FileStream file = GLib.FileStream.open (rpath, "w"); writer = new MarkupWriter (file); _renderer.set_writer (writer); - write_file_header (this.css_path, iface.full_name()); - write_navi_symbol (iface); - write_symbol_content (iface); + write_file_header (css_path, node.full_name()); + if (is_internal_node (node)) { + write_navi_symbol (node); + } else { + write_navi_leaf_symbol (node); + } + write_symbol_content (node); write_file_footer (); file = null; - } - public override void visit_class ( Class cl ) { - string rpath = this.get_real_path ( cl ); - - cl.visit_construction_methods ( this ); - cl.visit_classes ( this ); - cl.visit_structs ( this ); - cl.visit_enums ( this ); - cl.visit_delegates ( this ); - cl.visit_methods ( this ); - cl.visit_signals ( this ); - cl.visit_properties ( this ); - cl.visit_fields ( this ); - cl.visit_constants ( this ); - - GLib.FileStream file = GLib.FileStream.open ( rpath, "w"); - writer = new MarkupWriter (file); - _renderer.set_writer (writer); - write_file_header (this.css_path, cl.full_name()); - write_navi_symbol (cl); - write_symbol_content (cl); - write_file_footer (); - file = null; + node.accept_all_children (this); } - public override void visit_struct ( Struct stru ) { - string rpath = this.get_real_path ( stru ); - - stru.visit_construction_methods ( this ); - stru.visit_methods ( this ); - stru.visit_fields ( this ); - stru.visit_constants ( this ); - - GLib.FileStream file = GLib.FileStream.open ( rpath, "w"); - writer = new MarkupWriter (file); - _renderer.set_writer (writer); - write_file_header (this.css_path, stru.full_name()); - write_navi_symbol (stru); - write_symbol_content (stru); - write_file_footer (); - file = null; + private bool is_internal_node (Api.Node node) { + return node is Package + || node is Namespace + || node is Interface + || node is Class + || node is Struct; } - public override void visit_error_domain ( ErrorDomain errdom ) { - string rpath = this.get_real_path ( errdom ); - - errdom.visit_methods ( this ); - - GLib.FileStream file = GLib.FileStream.open ( rpath, "w"); - writer = new MarkupWriter (file); - _renderer.set_writer (writer); - write_file_header (this.css_path, errdom.full_name()); - write_navi_symbol (errdom); - write_symbol_content (errdom); - write_file_footer (); - file = null; + public override void visit_interface (Interface item) { + process_node (item); } - public override void visit_enum ( Enum en ) { - string rpath = this.get_real_path ( en ); - - en.visit_enum_values ( this ); - en.visit_methods ( this ); - - GLib.FileStream file = GLib.FileStream.open ( rpath, "w"); - writer = new MarkupWriter (file); - _renderer.set_writer (writer); - write_file_header (this.css_path, en.full_name()); - write_navi_symbol (en); - write_symbol_content (en); - write_file_footer (); - file = null; + public override void visit_class (Class item) { + process_node (item); } - public override void visit_property ( Property prop ) { - string rpath = this.get_real_path ( prop ); - - GLib.FileStream file = GLib.FileStream.open ( rpath, "w"); - writer = new MarkupWriter (file); - _renderer.set_writer (writer); - write_file_header (this.css_path, prop.full_name()); - write_navi_leaf_symbol (prop); - write_symbol_content (prop); - write_file_footer (); - file = null; + public override void visit_struct (Struct item) { + process_node (item); } - public override void visit_constant (Constant constant) { - string rpath = this.get_real_path ( constant ); - - GLib.FileStream file = GLib.FileStream.open ( rpath, "w"); - writer = new MarkupWriter (file); - _renderer.set_writer (writer); - write_file_header (this.css_path, constant.full_name()); - write_navi_leaf_symbol (constant); - write_symbol_content (constant); - write_file_footer (); - file = null; + public override void visit_error_domain (ErrorDomain item) { + process_node (item); } - public override void visit_field (Field field) { - string rpath = this.get_real_path ( field ); - - GLib.FileStream file = GLib.FileStream.open ( rpath, "w"); - writer = new MarkupWriter (file); - _renderer.set_writer (writer); - write_file_header (this.css_path, field.full_name()); - write_navi_leaf_symbol (field); - write_symbol_content (field); - write_file_footer (); - file = null; + public override void visit_enum (Enum item) { + process_node (item); } - public override void visit_error_code ( ErrorCode errcode ) { + public override void visit_property (Property item) { + process_node (item); } - public override void visit_enum_value ( Api.EnumValue enval ) { + public override void visit_constant (Constant item) { + process_node (item); } - public override void visit_delegate ( Delegate del ) { - string rpath = this.get_real_path ( del ); + public override void visit_field (Field item) { + process_node (item); + } - GLib.FileStream file = GLib.FileStream.open ( rpath, "w"); - writer = new MarkupWriter (file); - _renderer.set_writer (writer); - write_file_header (this.css_path, del.full_name()); - write_navi_leaf_symbol (del); - write_symbol_content (del); - write_file_footer (); - file = null; + public override void visit_error_code (ErrorCode item) { } - public override void visit_signal ( Api.Signal sig ) { - string rpath = this.get_real_path ( sig ); + public override void visit_enum_value (Api.EnumValue item) { + } - GLib.FileStream file = GLib.FileStream.open ( rpath, "w"); - writer = new MarkupWriter (file); - _renderer.set_writer (writer); - write_file_header (this.css_path, sig.full_name()); - write_navi_leaf_symbol (sig); - write_symbol_content (sig); - write_file_footer (); - file = null; + public override void visit_delegate (Delegate item) { + process_node (item); } - public override void visit_method (Method m) { - string rpath = this.get_real_path ( m ); + public override void visit_signal (Api.Signal item) { + process_node (item); + } - GLib.FileStream file = GLib.FileStream.open ( rpath, "w"); - writer = new MarkupWriter (file); - _renderer.set_writer (writer); - write_file_header (this.css_path, m.full_name()); - write_navi_leaf_symbol (m); - write_symbol_content (m); - write_file_footer (); - file = null; + public override void visit_method (Method item) { + process_node (item); } } - - - - [ModuleInit] public Type register_plugin ( ) { Valadoc.Html.get_html_link_imp = Valadoc.get_html_link; return typeof ( Valadoc.HtmlDoclet ); } - diff --git a/src/doclets/htmlhelpers/doclet/doclet.vala b/src/doclets/htmlhelpers/doclet/doclet.vala index cd3b4796b..31a1c8599 100755 --- a/src/doclets/htmlhelpers/doclet/doclet.vala +++ b/src/doclets/htmlhelpers/doclet/doclet.vala @@ -154,12 +154,10 @@ public abstract class Valadoc.Html.BasicDoclet : Api.Visitor, Doclet { } } - protected void fetch_subnamespace_names (NamespaceHandler pos, Gee.ArrayList lst) { - Gee.Collection nspaces = pos.get_namespace_list (); - - foreach (Namespace ns in nspaces) { - lst.add (ns); - this.fetch_subnamespace_names (ns, lst); + protected void fetch_subnamespace_names (Api.Node node, Gee.ArrayList namespaces) { + foreach (Api.Node child in node.get_children_by_type (Api.NodeType.NAMESPACE)) { + namespaces.add ((Namespace) child); + this.fetch_subnamespace_names (child, namespaces); } } @@ -387,23 +385,23 @@ public abstract class Valadoc.Html.BasicDoclet : Api.Visitor, Doclet { writer.end_tag ("div"); } - protected void write_child_namespaces (NamespaceHandler nh, Api.Node? parent) { - Gee.ArrayList nsl = new Gee.ArrayList (); - this.fetch_subnamespace_names (nh, nsl); + protected void write_child_namespaces (Api.Node node, Api.Node? parent) { + Gee.ArrayList namespaces = new Gee.ArrayList (); + this.fetch_subnamespace_names (node, namespaces); - if (nsl.size == 0) + if (namespaces.size == 0) return ; - if (nsl.size == 1) { - if (nsl.get(0).name == null) + if (namespaces.size == 1) { + if (namespaces.get(0).name == null) return ; } - bool with_childs = (parent == null)? false : parent is Package; + bool with_childs = parent != null && parent is Package; writer.start_tag ("h3", css_title).text ("Namespaces:").end_tag ("h3"); writer.start_tag ("ul", css_inline_navigation); - foreach (Namespace child in nsl) { + foreach (Namespace child in namespaces) { if (child.name != null) { writer.start_tag ("li", css_namespace); writer.link (get_link (child, parent), child.name); diff --git a/src/libvaladoc/Makefile.am b/src/libvaladoc/Makefile.am index ed4534f74..276494803 100644 --- a/src/libvaladoc/Makefile.am +++ b/src/libvaladoc/Makefile.am @@ -35,47 +35,30 @@ libvaladoc_la_VALASOURCES = \ documentation/wikiscanner.vala \ api/array.vala \ api/class.vala \ - api/classhandler.vala \ api/constant.vala \ - api/constanthandler.vala \ - api/constructionmethodhandler.vala \ api/delegate.vala \ - api/delegatehandler.vala \ api/enum.vala \ - api/enumhandler.vala \ api/enumvalue.vala \ api/errorcode.vala \ api/errordomain.vala \ - api/errordomainhandler.vala \ - api/exceptionlisthandler.vala \ api/field.vala \ - api/fieldhandler.vala \ api/formalparameter.vala \ api/interface.vala \ - api/interfacehandler.vala \ api/item.vala \ api/member.vala \ api/method.vala \ - api/methodhandler.vala \ api/namespace.vala \ - api/namespacehandler.vala \ api/node.vala \ api/nodebuilder.vala \ api/package.vala \ - api/parameterlisthandler.vala \ api/pointer.vala \ api/property.vala \ api/propertyaccessor.vala \ - api/propertyhandler.vala \ - api/returntypehandler.vala \ api/signal.vala \ - api/signalhandler.vala \ api/signaturebuilder.vala \ api/struct.vala \ - api/structhandler.vala \ api/symbol.vala \ api/symbolaccessibility.vala \ - api/templateparameterlisthandler.vala \ api/tree.vala \ api/typeparameter.vala \ api/typereference.vala \ @@ -181,3 +164,4 @@ vapi_DATA = \ valadoc-1.0.deps \ $(NULL) + diff --git a/src/libvaladoc/api/class.vala b/src/libvaladoc/api/class.vala index 9d5bd758b..81e49da10 100644 --- a/src/libvaladoc/api/class.vala +++ b/src/libvaladoc/api/class.vala @@ -20,7 +20,7 @@ using Gee; using Valadoc.Content; -public class Valadoc.Api.Class : TypeSymbol, ClassHandler, StructHandler, SignalHandler, MethodHandler, EnumHandler, PropertyHandler, ConstructionMethodHandler, FieldHandler, DelegateHandler, ConstantHandler, TemplateParameterListHandler { +public class Valadoc.Api.Class : TypeSymbol { private ArrayList interfaces; private Vala.Class vclass; @@ -50,10 +50,6 @@ public class Valadoc.Api.Class : TypeSymbol, ClassHandler, StructHandler, Signal return this.interfaces; } - internal bool is_vclass (Vala.Class vcl) { - return this.vclass == vcl; - } - public bool is_abstract { get { return this.vclass.is_abstract; @@ -139,3 +135,4 @@ public class Valadoc.Api.Class : TypeSymbol, ClassHandler, StructHandler, Signal return signature.get (); } } + diff --git a/src/libvaladoc/api/classhandler.vala b/src/libvaladoc/api/classhandler.vala deleted file mode 100644 index 4a61b6684..000000000 --- a/src/libvaladoc/api/classhandler.vala +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Valadoc.Api.- a documentation tool for vala. - * Copyright (C) 2008 Florian Brosch - * - * 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. - */ - -using Gee; - - -public interface Valadoc.Api.ClassHandler : Node { - protected Class? find_vclass (Vala.Class vcl) { - foreach (Class cl in get_class_list ()) { - if (cl.is_vclass (vcl)) { - return cl; - } - - var tmp = cl.find_vclass (vcl); - if (tmp != null) { - return tmp; - } - } - return null; - } - - public Gee.Collection get_class_list () { - return get_children_by_type (NodeType.CLASS); - } - - public void visit_classes (Visitor visitor) { - accept_children_by_type (NodeType.CLASS, visitor); - } -} - diff --git a/src/libvaladoc/api/constant.vala b/src/libvaladoc/api/constant.vala index dd48b355c..6de083c6b 100644 --- a/src/libvaladoc/api/constant.vala +++ b/src/libvaladoc/api/constant.vala @@ -20,7 +20,7 @@ using Gee; using Valadoc.Content; -public class Valadoc.Api.Constant : Member, ReturnTypeHandler { +public class Valadoc.Api.Constant : Member { private Vala.Constant vconst; public TypeReference? type_reference { @@ -36,8 +36,7 @@ public class Valadoc.Api.Constant : Member, ReturnTypeHandler { base (symbol, parent); this.vconst = symbol; - var vret = this.vconst.type_reference; - this.set_ret_type (vret); + type_reference = new TypeReference (symbol.type_reference, this); } public string get_cname () { @@ -45,7 +44,7 @@ public class Valadoc.Api.Constant : Member, ReturnTypeHandler { } protected override void resolve_type_references (Tree root) { - this.set_return_type_references (root); + type_reference.resolve_type_references (root); } protected override Inline build_signature () { @@ -63,3 +62,4 @@ public class Valadoc.Api.Constant : Member, ReturnTypeHandler { visitor.visit_constant (this); } } + diff --git a/src/libvaladoc/api/constanthandler.vala b/src/libvaladoc/api/constanthandler.vala deleted file mode 100644 index a3975c3dc..000000000 --- a/src/libvaladoc/api/constanthandler.vala +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Valadoc.Api.- a documentation tool for vala. - * Copyright (C) 2008 Florian Brosch - * - * 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. - */ - -using Gee; - - -public interface Valadoc.Api.ConstantHandler : Node { - public Collection get_constant_list () { - return get_children_by_type (NodeType.CONSTANT); - } - - public void visit_constants (Visitor visitor) { - accept_children_by_type (NodeType.CONSTANT, visitor); - } -} diff --git a/src/libvaladoc/api/constructionmethodhandler.vala b/src/libvaladoc/api/constructionmethodhandler.vala deleted file mode 100644 index 63f3f94bc..000000000 --- a/src/libvaladoc/api/constructionmethodhandler.vala +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Valadoc.Api.- a documentation tool for vala. - * Copyright (C) 2008 Florian Brosch - * - * 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. - */ - -using Gee; - - -public interface Valadoc.Api.ConstructionMethodHandler : Node { - public Collection get_construction_method_list () { - return get_children_by_type (NodeType.CREATION_METHOD); - } - - public void visit_construction_methods (Visitor visitor) { - accept_children_by_type (NodeType.CREATION_METHOD, visitor); - } -} - diff --git a/src/libvaladoc/api/delegate.vala b/src/libvaladoc/api/delegate.vala index 36debeb1f..cf88e7353 100644 --- a/src/libvaladoc/api/delegate.vala +++ b/src/libvaladoc/api/delegate.vala @@ -20,7 +20,7 @@ using Gee; using Valadoc.Content; -public class Valadoc.Api.Delegate : TypeSymbol, ParameterListHandler, ReturnTypeHandler, TemplateParameterListHandler, ExceptionHandler { +public class Valadoc.Api.Delegate : TypeSymbol { private Vala.Delegate vdelegate; public Delegate (Vala.Delegate symbol, Node parent) { @@ -28,8 +28,7 @@ public class Valadoc.Api.Delegate : TypeSymbol, ParameterListHandler, ReturnType this.vdelegate = symbol; - var ret = this.vdelegate.return_type; - this.set_ret_type (ret); + type_reference = new TypeReference (symbol.return_type, this); } public string? get_cname () { @@ -54,10 +53,7 @@ public class Valadoc.Api.Delegate : TypeSymbol, ParameterListHandler, ReturnType } protected override void resolve_type_references (Tree root) { - this.set_return_type_references (root); - - var vexceptionlst = this.vdelegate.get_error_types (); - this.add_exception_list (root, vexceptionlst); + type_reference.resolve_type_references (root); base.resolve_type_references (root); } @@ -116,3 +112,4 @@ public class Valadoc.Api.Delegate : TypeSymbol, ParameterListHandler, ReturnType return signature.get (); } } + diff --git a/src/libvaladoc/api/delegatehandler.vala b/src/libvaladoc/api/delegatehandler.vala deleted file mode 100644 index 70201f527..000000000 --- a/src/libvaladoc/api/delegatehandler.vala +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Valadoc.Api.- a documentation tool for vala. - * Copyright (C) 2008 Florian Brosch - * - * 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. - */ - -using Gee; - -public interface Valadoc.Api.DelegateHandler : Node { - public Gee.Collection get_delegate_list () { - return get_children_by_type (NodeType.DELEGATE); - } - - public void visit_delegates (Visitor visitor) { - accept_children_by_type (NodeType.DELEGATE, visitor); - } -} diff --git a/src/libvaladoc/api/enum.vala b/src/libvaladoc/api/enum.vala index 4beade841..3f5bae776 100644 --- a/src/libvaladoc/api/enum.vala +++ b/src/libvaladoc/api/enum.vala @@ -20,7 +20,7 @@ using Gee; using Valadoc.Content; -public class Valadoc.Api.Enum : TypeSymbol, MethodHandler { +public class Valadoc.Api.Enum : TypeSymbol { public Enum (Vala.Enum symbol, Node parent) { base (symbol, parent); this.venum = symbol; @@ -30,15 +30,6 @@ public class Valadoc.Api.Enum : TypeSymbol, MethodHandler { return this.venum.get_cname(); } - // rename: get_enum_value_list - public Collection get_enum_values () { - return get_children_by_type (NodeType.ENUM_VALUE); - } - - public void visit_enum_values (Visitor visitor) { - accept_children_by_type (NodeType.ENUM_VALUE, visitor); - } - public override NodeType node_type { get { return NodeType.ENUM; } } public override void accept (Visitor visitor) { @@ -55,3 +46,4 @@ public class Valadoc.Api.Enum : TypeSymbol, MethodHandler { .get (); } } + diff --git a/src/libvaladoc/api/enumhandler.vala b/src/libvaladoc/api/enumhandler.vala deleted file mode 100644 index f6e80808b..000000000 --- a/src/libvaladoc/api/enumhandler.vala +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Valadoc.Api.- a documentation tool for vala. - * Copyright (C) 2008 Florian Brosch - * - * 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. - */ - -using Gee; - - -public interface Valadoc.Api.EnumHandler : Node { - public Collection get_enum_list () { - return get_children_by_type (NodeType.ENUM); - } - - public void visit_enums (Visitor visitor) { - accept_children_by_type (NodeType.ENUM, visitor); - } -} - diff --git a/src/libvaladoc/api/errordomain.vala b/src/libvaladoc/api/errordomain.vala index 3019bd15c..d8c5e7692 100644 --- a/src/libvaladoc/api/errordomain.vala +++ b/src/libvaladoc/api/errordomain.vala @@ -21,7 +21,7 @@ using Gee; using Valadoc.Content; -public class Valadoc.Api.ErrorDomain : TypeSymbol, MethodHandler { +public class Valadoc.Api.ErrorDomain : TypeSymbol { private Vala.ErrorDomain verrdom; public ErrorDomain (Vala.ErrorDomain symbol, Node parent) { @@ -33,14 +33,6 @@ public class Valadoc.Api.ErrorDomain : TypeSymbol, MethodHandler { return this.verrdom.get_cname(); } - public void visit_error_codes (Visitor visitor) { - accept_children_by_type (NodeType.ERROR_CODE, visitor); - } - - public Collection get_error_code_list () { - return get_children_by_type (NodeType.ERROR_CODE); - } - public override NodeType node_type { get { return NodeType.ERROR_DOMAIN; } } public override void accept (Visitor visitor) { @@ -55,3 +47,4 @@ public class Valadoc.Api.ErrorDomain : TypeSymbol, MethodHandler { .get (); } } + diff --git a/src/libvaladoc/api/errordomainhandler.vala b/src/libvaladoc/api/errordomainhandler.vala deleted file mode 100644 index a42b538bc..000000000 --- a/src/libvaladoc/api/errordomainhandler.vala +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Valadoc.Api.- a documentation tool for vala. - * Copyright (C) 2008 Florian Brosch - * - * 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. - */ - -using Gee; - - -public interface Valadoc.Api.ErrorDomainHandler : Node { - public Collection get_error_domain_list () { - return get_children_by_type (NodeType.ERROR_DOMAIN); - } - - public void visit_error_domains (Visitor visitor) { - accept_children_by_type (NodeType.ERROR_DOMAIN, visitor); - } -} diff --git a/src/libvaladoc/api/exceptionlisthandler.vala b/src/libvaladoc/api/exceptionlisthandler.vala deleted file mode 100644 index 9f24bd988..000000000 --- a/src/libvaladoc/api/exceptionlisthandler.vala +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Valadoc.Api.- a documentation tool for vala. - * Copyright (C) 2008 Florian Brosch - * - * 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. - */ - -using Gee; - - -// rename to ExceptionListHandler -public interface Valadoc.Api.ExceptionHandler : Node { - - public Collection get_error_domains () { - return get_children_by_type (NodeType.ERROR_DOMAIN); - } - - public void add_exception_list (Tree root, Vala.Collection vexceptions) { - foreach (Vala.DataType vtype in vexceptions) { - if (((Vala.ErrorType) vtype).error_domain == null) { - add_child (glib_error); - } else { - ErrorDomain type = (ErrorDomain) root.search_vala_symbol (((Vala.ErrorType) vtype).error_domain); - add_child (type); - } - } - } -} - diff --git a/src/libvaladoc/api/field.vala b/src/libvaladoc/api/field.vala index a3272a391..b64066685 100644 --- a/src/libvaladoc/api/field.vala +++ b/src/libvaladoc/api/field.vala @@ -20,15 +20,14 @@ using Gee; using Valadoc.Content; -public class Valadoc.Api.Field : Member, ReturnTypeHandler { +public class Valadoc.Api.Field : Member { private Vala.Field vfield; public Field (Vala.Field symbol, Node parent) { base (symbol, parent); this.vfield = symbol; - var vret = this.vfield.field_type; - this.set_ret_type (vret); + type_reference = new TypeReference (symbol.field_type, this); } public string? get_cname () { @@ -57,7 +56,7 @@ public class Valadoc.Api.Field : Member, ReturnTypeHandler { } protected override void resolve_type_references (Tree root) { - this.set_return_type_references (root); + type_reference.resolve_type_references (root); base.resolve_type_references (root); } @@ -84,3 +83,4 @@ public class Valadoc.Api.Field : Member, ReturnTypeHandler { visitor.visit_field (this); } } + diff --git a/src/libvaladoc/api/fieldhandler.vala b/src/libvaladoc/api/fieldhandler.vala deleted file mode 100644 index 4f54010a5..000000000 --- a/src/libvaladoc/api/fieldhandler.vala +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Valadoc.Api.- a documentation tool for vala. - * Copyright (C) 2008 Florian Brosch - * - * 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. - */ - -using Gee; - - -public interface Valadoc.Api.FieldHandler : Node { - public Collection get_field_list () { - return get_children_by_type (NodeType.FIELD); - } - - public void visit_fields (Visitor visitor) { - accept_children_by_type (NodeType.FIELD, visitor); - } -} diff --git a/src/libvaladoc/api/formalparameter.vala b/src/libvaladoc/api/formalparameter.vala index 478fc7cef..840b7456c 100644 --- a/src/libvaladoc/api/formalparameter.vala +++ b/src/libvaladoc/api/formalparameter.vala @@ -20,15 +20,14 @@ using Gee; using Valadoc.Content; -public class Valadoc.Api.FormalParameter : Symbol, ReturnTypeHandler { +public class Valadoc.Api.FormalParameter : Symbol { private Vala.FormalParameter vformalparam; public FormalParameter (Vala.FormalParameter symbol, Node parent) { base (symbol, parent); this.vformalparam = symbol; - var vformparam = this.vformalparam.parameter_type; - this.set_ret_type (vformparam); + type_reference = new TypeReference (symbol.parameter_type, this); } public bool is_out { @@ -71,7 +70,7 @@ public class Valadoc.Api.FormalParameter : Symbol, ReturnTypeHandler { return; } - this.set_return_type_references (root); + type_reference.resolve_type_references (root); base.resolve_type_references (root); } @@ -100,3 +99,4 @@ public class Valadoc.Api.FormalParameter : Symbol, ReturnTypeHandler { return signature.get (); } } + diff --git a/src/libvaladoc/api/interface.vala b/src/libvaladoc/api/interface.vala index 17030f05c..de718031f 100644 --- a/src/libvaladoc/api/interface.vala +++ b/src/libvaladoc/api/interface.vala @@ -20,7 +20,7 @@ using Gee; using Valadoc.Content; -public class Valadoc.Api.Interface : TypeSymbol, SignalHandler, PropertyHandler, FieldHandler, ConstantHandler, TemplateParameterListHandler, MethodHandler, DelegateHandler, EnumHandler, StructHandler, ClassHandler { +public class Valadoc.Api.Interface : TypeSymbol { public Interface (Vala.Interface symbol, Node parent) { base (symbol, parent); this.vinterface = symbol; @@ -119,3 +119,4 @@ public class Valadoc.Api.Interface : TypeSymbol, SignalHandler, PropertyHandler, return signature.get (); } } + diff --git a/src/libvaladoc/api/interfacehandler.vala b/src/libvaladoc/api/interfacehandler.vala deleted file mode 100644 index a4c323a24..000000000 --- a/src/libvaladoc/api/interfacehandler.vala +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Valadoc.Api.- a documentation tool for vala. - * Copyright (C) 2008 Florian Brosch - * - * 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. - */ - -using Gee; - - -public interface Valadoc.Api.InterfaceHandler : Node { - public Collection get_interface_list () { - return get_children_by_type (NodeType.INTERFACE); - } - - public void visit_interfaces (Visitor visitor) { - accept_children_by_type (NodeType.INTERFACE, visitor); - } -} diff --git a/src/libvaladoc/api/method.vala b/src/libvaladoc/api/method.vala index 3e02aeb82..93f9a83c0 100644 --- a/src/libvaladoc/api/method.vala +++ b/src/libvaladoc/api/method.vala @@ -20,15 +20,14 @@ using Gee; using Valadoc.Content; -public class Valadoc.Api.Method : Member, ParameterListHandler, ExceptionHandler, TemplateParameterListHandler, ReturnTypeHandler { +public class Valadoc.Api.Method : Member { private Vala.Method vmethod; public Method (Vala.Method symbol, Node parent) { base (symbol, parent); this.vmethod = symbol; - var vret = this.vmethod.return_type; - this.set_ret_type (vret); + type_reference = new TypeReference (symbol.return_type, this); } public string? get_cname () { @@ -119,10 +118,7 @@ public class Valadoc.Api.Method : Member, ParameterListHandler, ExceptionHandler this.base_method = (Method?) root.search_vala_symbol (vm); } - var vexceptionlst = this.vmethod.get_error_types (); - this.add_exception_list (root, vexceptionlst); - - this.set_return_type_references (root); + type_reference.resolve_type_references (root); base.resolve_type_references (root); } diff --git a/src/libvaladoc/api/methodhandler.vala b/src/libvaladoc/api/methodhandler.vala deleted file mode 100644 index a5899eec0..000000000 --- a/src/libvaladoc/api/methodhandler.vala +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Valadoc.Api.- a documentation tool for vala. - * Copyright (C) 2008 Florian Brosch - * - * 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. - */ - -using Gee; - -public interface Valadoc.Api.MethodHandler : Node { - public void visit_methods (Visitor visitor) { - accept_children_by_type (NodeType.METHOD, visitor); - } - - public Collection get_method_list () { - return get_children_by_type (NodeType.METHOD); - } -} diff --git a/src/libvaladoc/api/namespace.vala b/src/libvaladoc/api/namespace.vala index 1253e1084..15ed3450f 100644 --- a/src/libvaladoc/api/namespace.vala +++ b/src/libvaladoc/api/namespace.vala @@ -20,13 +20,10 @@ using Gee; using Valadoc.Content; -public class Valadoc.Api.Namespace : Symbol, MethodHandler, FieldHandler, NamespaceHandler, ErrorDomainHandler, - EnumHandler, ClassHandler, StructHandler, InterfaceHandler, - DelegateHandler, ConstantHandler -{ +public class Valadoc.Api.Namespace : Symbol { private Vala.Comment source_comment; - public Namespace (Vala.Namespace symbol, NamespaceHandler parent) { + public Namespace (Vala.Namespace symbol, Api.Node parent) { base (symbol, parent); this.vnspace = symbol; @@ -67,8 +64,5 @@ public class Valadoc.Api.Namespace : Symbol, MethodHandler, FieldHandler, Namesp private get; set; } - - internal bool is_vnspace (Vala.Namespace vns) { - return this.vnspace == vns; - } } + diff --git a/src/libvaladoc/api/namespacehandler.vala b/src/libvaladoc/api/namespacehandler.vala deleted file mode 100644 index f21bd3e0c..000000000 --- a/src/libvaladoc/api/namespacehandler.vala +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Valadoc.Api.- a documentation tool for vala. - * Copyright (C) 2008 Florian Brosch - * - * 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. - */ - -using Gee; - -public interface Valadoc.Api.NamespaceHandler : Node { - public Collection get_namespace_list (bool filtered = true) { - return get_children_by_type (NodeType.NAMESPACE, filtered); - } - - public void visit_namespaces (Visitor visitor) { - accept_children_by_type (NodeType.NAMESPACE, visitor); - } - - private ArrayList create_parent_vnamespace_list (Vala.Symbol vsymbol) { - var lst = new ArrayList (); - - while (vsymbol != null) { - if (vsymbol is Vala.Namespace) { - lst.insert ( 0, (Vala.Namespace)vsymbol ); - } - vsymbol = vsymbol.parent_symbol; - } - return lst; - } - - internal Namespace get_namespace_helper (Vala.Symbol node, Gee.List vnspaces, int pos) { - Vala.Namespace vns = vnspaces.get (pos); - - Namespace ns = this.find_namespace_without_childs (vns); - if (ns == null) { - ns = new Namespace (vns, this); - add_child (ns); - } - - if (vnspaces.size == pos+1) { - return ns; - } - - return ns.get_namespace_helper (node, vnspaces, pos+1); - } - - protected Namespace get_namespace (Vala.Symbol node) { - Vala.Symbol vnd = ((Vala.Symbol)node).parent_symbol; - if (vnd is Vala.Namespace == false) { - vnd = vnd.parent_symbol; - } - - Vala.Namespace vnspace = (Vala.Namespace)vnd; - var nspace = this.find_namespace (vnspace); - if (nspace != null) { - return nspace; - } - - var vnspaces = this.create_parent_vnamespace_list (node); - - if (vnspaces.size > 2) { - return this.get_namespace_helper (node, vnspaces, 1); - } else { - var ns = new Namespace (vnspace, this); - add_child (ns); - return ns; - } - } - - internal Namespace? find_vnamespace_helper (Gee.List vnspaces, int pos) { - Vala.Namespace? vns = vnspaces.get (pos); - if (vns == null) { - return null; - } - - foreach (Namespace ns in get_namespace_list (false)) { - if (!ns.is_vnspace(vns)) { - continue; - } - if (pos+1 == vnspaces.size) { - return ns; - } - return ns.find_vnamespace_helper (vnspaces, pos+1); - } - - return null; - } - - internal Namespace find_namespace_without_childs (Vala.Namespace vns) { - Namespace ns2 = null; - - foreach (Namespace ns in get_namespace_list (false)) { - if (ns.is_vnspace(vns)) { - ns2 = ns; - } - } - - return ns2; - } - - internal Namespace find_namespace (Vala.Namespace vns) { - var vnspaces = this.create_parent_vnamespace_list (vns); - - return this.find_vnamespace_helper (vnspaces, vnspaces.index_of (vns)); - } -} diff --git a/src/libvaladoc/api/node.vala b/src/libvaladoc/api/node.vala index 99efbf8de..b1c875213 100644 --- a/src/libvaladoc/api/node.vala +++ b/src/libvaladoc/api/node.vala @@ -154,6 +154,16 @@ public abstract class Valadoc.Api.Node : Item, Visitable, Documentation { } } + public void accept_all_children (Visitor visitor) { + foreach (Gee.List children in per_type_children.values) { + foreach (Node node in children) { + if (node.do_document) { + node.accept (visitor); + } + } + } + } + public Node? find_by_name (string name) { return per_name_children.get (name); } diff --git a/src/libvaladoc/api/nodebuilder.vala b/src/libvaladoc/api/nodebuilder.vala index 7b79fd01f..5662a5bfb 100644 --- a/src/libvaladoc/api/nodebuilder.vala +++ b/src/libvaladoc/api/nodebuilder.vala @@ -48,8 +48,7 @@ internal class Valadoc.Api.NodeBuilder : Vala.CodeVisitor { Vala.SourceFile source_file = element.source_reference.file; Package package = find_package_for (source_file); - Namespace ns = package.get_namespace (element); - return ns; + return package.get_namespace (root, element); } private Package? find_package_for (Vala.SourceFile source_file) { @@ -224,3 +223,4 @@ internal class Valadoc.Api.NodeBuilder : Vala.CodeVisitor { } } + diff --git a/src/libvaladoc/api/package.vala b/src/libvaladoc/api/package.vala index f9f9c2b20..a7a780cbb 100644 --- a/src/libvaladoc/api/package.vala +++ b/src/libvaladoc/api/package.vala @@ -20,9 +20,7 @@ using Gee; using Valadoc.Content; - - -public class Valadoc.Api.Package : Node, NamespaceHandler { +public class Valadoc.Api.Package : Node { private ArrayList vfiles = new ArrayList (); internal void add_file (Vala.SourceFile vfile) { @@ -88,7 +86,6 @@ public class Valadoc.Api.Package : Node, NamespaceHandler { } } - // TODO Remove internal bool is_vpackage (Vala.SourceFile vfile) { return this.vfiles.contains (vfile); } @@ -113,4 +110,35 @@ public class Valadoc.Api.Package : Node, NamespaceHandler { .append (name) .get (); } + + protected Namespace get_namespace (Tree root, Vala.Symbol symbol) { + Vala.Symbol namespace_symbol = symbol; + while (!(namespace_symbol is Vala.Namespace)) { + namespace_symbol = namespace_symbol.parent_symbol; + } + + // Try to find it first + var ns = (Namespace) root.search_vala_symbol_in (namespace_symbol, this); + if (ns != null) { + return ns; + } + + // Find parent namespace and use it as parent if existing + var parent_namespace_symbol = namespace_symbol.parent_symbol; + + if (parent_namespace_symbol != null) { + ns = (Namespace) get_namespace (root, parent_namespace_symbol); + if (ns != null) { + var new_namespace = new Namespace ((Vala.Namespace) namespace_symbol, ns); + add_child (new_namespace); + return new_namespace; + } + } + + // Else take this package as parent + var new_namespace = new Namespace ((Vala.Namespace) namespace_symbol, this); + add_child (new_namespace); + return new_namespace; + } } + diff --git a/src/libvaladoc/api/parameterlisthandler.vala b/src/libvaladoc/api/parameterlisthandler.vala deleted file mode 100644 index 5b5e55bd4..000000000 --- a/src/libvaladoc/api/parameterlisthandler.vala +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Valadoc.Api.- a documentation tool for vala. - * Copyright (C) 2008 Florian Brosch - * - * 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. - */ - -using Gee; - - -// TODO Rename FormalParameters -public interface Valadoc.Api.ParameterListHandler : Node { - public Gee.List param_list { - owned get { return get_parameter_list (); } - } - - public Gee.List get_parameter_list () { - return (Gee.List) get_children_by_type (NodeType.FORMAL_PARAMETER); - } -} - diff --git a/src/libvaladoc/api/property.vala b/src/libvaladoc/api/property.vala index f42a8fe03..68af7dfb7 100644 --- a/src/libvaladoc/api/property.vala +++ b/src/libvaladoc/api/property.vala @@ -20,7 +20,7 @@ using Gee; using Valadoc.Content; -public class Valadoc.Api.Property : Member, ReturnTypeHandler { +public class Valadoc.Api.Property : Member { private Vala.Property vproperty; public Property (Vala.Property symbol, Node parent) { @@ -28,8 +28,7 @@ public class Valadoc.Api.Property : Member, ReturnTypeHandler { this.vproperty = symbol; - var ret = this.vproperty.property_type; - this.set_ret_type (ret); + type_reference = new TypeReference (symbol.property_type, this); if (this.vproperty.get_accessor != null) { this.getter = new PropertyAccessor (this.vproperty.get_accessor, this); @@ -103,7 +102,8 @@ public class Valadoc.Api.Property : Member, ReturnTypeHandler { if (vp != null) { this.base_property = (Property?) root.search_vala_symbol (vp); } - this.set_return_type_references (root); + + type_reference.resolve_type_references (root); } protected override Inline build_signature () { @@ -141,3 +141,4 @@ public class Valadoc.Api.Property : Member, ReturnTypeHandler { visitor.visit_property (this); } } + diff --git a/src/libvaladoc/api/propertyhandler.vala b/src/libvaladoc/api/propertyhandler.vala deleted file mode 100644 index f4445ca0e..000000000 --- a/src/libvaladoc/api/propertyhandler.vala +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Valadoc.Api.- a documentation tool for vala. - * Copyright (C) 2008 Florian Brosch - * - * 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. - */ - -using Gee; - -public interface Valadoc.Api.PropertyHandler : Node { - protected bool is_overwritten_property (Property prop) { - foreach (Property p in get_property_list ()) { - if (p.parent != this) { - continue ; - } - if (!p.is_override) { - continue ; - } - if (p.equals (prop)) { - return true; - } - } - return false; - } - - public Collection get_property_list () { - return get_children_by_type (NodeType.PROPERTY); - } - - public void visit_properties (Visitor visitor) { - accept_children_by_type (NodeType.PROPERTY, visitor); - } -} diff --git a/src/libvaladoc/api/returntypehandler.vala b/src/libvaladoc/api/returntypehandler.vala deleted file mode 100644 index 5180fb661..000000000 --- a/src/libvaladoc/api/returntypehandler.vala +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Valadoc.Api.- a documentation tool for vala. - * Copyright (C) 2008 Florian Brosch - * - * 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. - */ - -using Gee; - - -public interface Valadoc.Api.ReturnTypeHandler : Item { - public abstract TypeReference? type_reference { - protected set; - get; - } - - internal void set_return_type_references (Tree root) { - if ( this.type_reference == null ) - return ; - - this.type_reference.resolve_type_references (root); - } - - // rename - internal void set_ret_type ( Vala.DataType? vtref ) { - var tmp = new TypeReference (vtref, this); - this.type_reference = tmp; - } -} - diff --git a/src/libvaladoc/api/signal.vala b/src/libvaladoc/api/signal.vala index 7fdf206d1..b8161a967 100644 --- a/src/libvaladoc/api/signal.vala +++ b/src/libvaladoc/api/signal.vala @@ -20,7 +20,7 @@ using Gee; using Valadoc.Content; -public class Valadoc.Api.Signal : Member, ParameterListHandler, ReturnTypeHandler { +public class Valadoc.Api.Signal : Member { private Vala.Signal vsignal; public Signal (Vala.Signal symbol, Node parent) { @@ -28,8 +28,7 @@ public class Valadoc.Api.Signal : Member, ParameterListHandler, ReturnTypeHandle this.vsignal = symbol; - var ret = this.vsignal.return_type; - this.set_ret_type (ret); + type_reference = new TypeReference (symbol.return_type, this); } public string? get_cname () { @@ -42,7 +41,7 @@ public class Valadoc.Api.Signal : Member, ParameterListHandler, ReturnTypeHandle } protected override void resolve_type_references (Tree root) { - this.set_return_type_references (root); + type_reference.resolve_type_references (root); base.resolve_type_references (root); } @@ -85,3 +84,4 @@ public class Valadoc.Api.Signal : Member, ParameterListHandler, ReturnTypeHandle visitor.visit_signal (this); } } + diff --git a/src/libvaladoc/api/signalhandler.vala b/src/libvaladoc/api/signalhandler.vala deleted file mode 100644 index 311091362..000000000 --- a/src/libvaladoc/api/signalhandler.vala +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Valadoc.Api.- a documentation tool for vala. - * Copyright (C) 2008 Florian Brosch - * - * 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. - */ - -using Gee; - -public interface Valadoc.Api.SignalHandler : Node { - public void visit_signals (Visitor visitor) { - accept_children_by_type (NodeType.SIGNAL, visitor); - } - - public Collection get_signal_list () { - return get_children_by_type (NodeType.SIGNAL); - } -} diff --git a/src/libvaladoc/api/struct.vala b/src/libvaladoc/api/struct.vala index 21d74ddc6..de4059172 100644 --- a/src/libvaladoc/api/struct.vala +++ b/src/libvaladoc/api/struct.vala @@ -20,7 +20,7 @@ using Gee; using Valadoc.Content; -public class Valadoc.Api.Struct : TypeSymbol, MethodHandler, ConstructionMethodHandler, FieldHandler, ConstantHandler, TemplateParameterListHandler { +public class Valadoc.Api.Struct : TypeSymbol { private Vala.Struct vstruct; public Struct (Vala.Struct symbol, Node parent) { @@ -88,3 +88,4 @@ public class Valadoc.Api.Struct : TypeSymbol, MethodHandler, ConstructionMethodH return signature.get (); } } + diff --git a/src/libvaladoc/api/structhandler.vala b/src/libvaladoc/api/structhandler.vala deleted file mode 100644 index 0a2c92213..000000000 --- a/src/libvaladoc/api/structhandler.vala +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Valadoc.Api.- a documentation tool for vala. - * Copyright (C) 2008 Florian Brosch - * - * 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. - */ - -using Gee; - -public interface Valadoc.Api.StructHandler : Node { - public Collection get_struct_list () { - return get_children_by_type (NodeType.STRUCT); - } - - public void visit_structs (Visitor visitor) { - accept_children_by_type (NodeType.STRUCT, visitor); - } -} diff --git a/src/libvaladoc/api/symbol.vala b/src/libvaladoc/api/symbol.vala index 472796312..011e6254c 100644 --- a/src/libvaladoc/api/symbol.vala +++ b/src/libvaladoc/api/symbol.vala @@ -103,4 +103,18 @@ public abstract class Valadoc.Api.Symbol : Node, SymbolAccessibility { return "private"; } } + + protected override void resolve_type_references (Tree root) { + base.resolve_type_references (root); + + foreach (Vala.DataType type in symbol.get_error_types ()) { + var error_type = type as Vala.ErrorType; + if (error_type.error_domain == null) { + add_child (glib_error); + } else { + add_child (root.search_vala_symbol (error_type.error_domain)); + } + } + } } + diff --git a/src/libvaladoc/api/templateparameterlisthandler.vala b/src/libvaladoc/api/templateparameterlisthandler.vala deleted file mode 100644 index d4f496f37..000000000 --- a/src/libvaladoc/api/templateparameterlisthandler.vala +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Valadoc.Api.- a documentation tool for vala. - * Copyright (C) 2008 Florian Brosch - * - * 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. - */ - -using Gee; - - -public interface Valadoc.Api.TemplateParameterListHandler : Node { - public Collection get_template_param_list () { - return get_children_by_type (NodeType.TYPE_PARAMETER, false); - } -} - diff --git a/src/libvaladoc/api/tree.vala b/src/libvaladoc/api/tree.vala index 41b954e2a..bc4ec7e4f 100644 --- a/src/libvaladoc/api/tree.vala +++ b/src/libvaladoc/api/tree.vala @@ -56,6 +56,12 @@ public class Valadoc.Api.Tree { visitor.visit_tree (this); } + public void accept_children (Visitor visitor) { + foreach (Node node in packages) { + node.accept (visitor); + } + } + private Node? search_relative_to (Node element, string[] path) { Api.Node? node = element; foreach (string name in path) { @@ -153,11 +159,11 @@ public class Valadoc.Api.Tree { } /* default packages */ - if (!this.add_package ("glib-2.0")) { // + if (!this.add_package ("glib-2.0")) { Vala.Report.error (null, "glib-2.0 not found in specified Vala API directories"); } - if (!this.add_package ("gobject-2.0")) { // + if (!this.add_package ("gobject-2.0")) { Vala.Report.error (null, "gobject-2.0 not found in specified Vala API directories"); } } @@ -329,13 +335,15 @@ public class Valadoc.Api.Tree { } } - internal Node? search_vala_symbol (Vala.Symbol? vnode) { - if (vnode == null) { - return null; - } + internal Symbol? search_vala_symbol (Vala.Symbol symbol) { + Vala.SourceFile source_file = symbol.source_reference.file; + Package package = this.find_file (source_file); + return search_vala_symbol_in (symbol, package); + } + internal Symbol? search_vala_symbol_in (Vala.Symbol symbol, Package package) { ArrayList params = new ArrayList (); - for (Vala.Symbol iter = vnode; iter != null; iter = iter.parent_symbol) { + for (Vala.Symbol iter = symbol; iter != null; iter = iter.parent_symbol) { if (iter is Vala.DataType) { params.insert (0, ((Vala.DataType)iter).data_type); } else { @@ -353,17 +361,14 @@ public class Valadoc.Api.Tree { } } - Vala.SourceFile vfile = vnode.source_reference.file; - Package file = this.find_file(vfile); - - Api.Node? node = file; - foreach (Vala.Symbol symbol in params) { - node = node.find_by_symbol (symbol); + Api.Node? node = package; + foreach (Vala.Symbol a_symbol in params) { + node = node.find_by_symbol (a_symbol); if (node == null) { return null; } } - return node; + return (Symbol) node; } private Package? get_external_package_by_name (string name) { @@ -375,3 +380,4 @@ public class Valadoc.Api.Tree { return null; } } + diff --git a/src/libvaladoc/api/typeparameter.vala b/src/libvaladoc/api/typeparameter.vala index 450b1e0f3..88a1946ba 100644 --- a/src/libvaladoc/api/typeparameter.vala +++ b/src/libvaladoc/api/typeparameter.vala @@ -20,17 +20,12 @@ using Gee; using Valadoc.Content; -public class Valadoc.Api.TypeParameter : Symbol, ReturnTypeHandler { +public class Valadoc.Api.TypeParameter : Symbol { public TypeParameter (Vala.TypeParameter symbol, Node parent) { base (symbol, parent); } - public TypeReference? type_reference { - protected set; - get; - } - protected override Inline build_signature () { return new SignatureBuilder () .append (name) @@ -43,3 +38,4 @@ public class Valadoc.Api.TypeParameter : Symbol, ReturnTypeHandler { visitor.visit_type_parameter (this); } } + diff --git a/src/libvaladoc/api/typereference.vala b/src/libvaladoc/api/typereference.vala index fad207203..610d6b6fb 100644 --- a/src/libvaladoc/api/typereference.vala +++ b/src/libvaladoc/api/typereference.vala @@ -194,7 +194,7 @@ public class Valadoc.Api.TypeReference : Item { } } else if (vtyperef is Vala.DelegateType) { this.data_type = root.search_vala_symbol (((Vala.DelegateType) vtyperef).delegate_symbol); - } else { + } else if (vtyperef.data_type != null) { this.data_type = root.search_vala_symbol (vtyperef.data_type); } @@ -250,3 +250,4 @@ public class Valadoc.Api.TypeReference : Item { return signature.get (); } } +