From d144372cfd690471ce9253fbff72de7b66015a72 Mon Sep 17 00:00:00 2001 From: Rico Tzschichholz Date: Tue, 30 Jul 2019 12:54:56 +0200 Subject: libvaladoc: Don't traverse into close circles with parent SymbolResolver.resolve_thrown_list() adds error-type nodes which are allowed to be NodeType.ERROR_DOMAIN and NodeType.CLASS. This can result in a cycle on invoking Node.accept_all_children(), Node.parse_comments() or Node.check_comments() Fixes https://gitlab.gnome.org/GNOME/vala/issues/829 --- libvaladoc/api/node.vala | 9 +++++++++ valadoc/tests/drivers/api-test.data.vapi | 1 + valadoc/tests/drivers/generic-api-test.vala | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/libvaladoc/api/node.vala b/libvaladoc/api/node.vala index 079c7ee44..6b41e5e9e 100644 --- a/libvaladoc/api/node.vala +++ b/libvaladoc/api/node.vala @@ -118,6 +118,9 @@ public abstract class Valadoc.Api.Node : Item, Documentation { do_document = true; foreach (Node node in per_name_children.get_values ()) { + if (this.parent == node) { + continue; + } if (node.is_browsable (settings)) { node.parse_comments (settings, parser); } @@ -130,6 +133,9 @@ public abstract class Valadoc.Api.Node : Item, Documentation { internal override void check_comments (Settings settings, DocumentationParser parser) { foreach (Node node in per_name_children.get_values ()) { + if (this.parent == node) { + continue; + } if (node.is_browsable (settings)) { node.check_comments (settings, parser); } @@ -277,6 +283,9 @@ public abstract class Valadoc.Api.Node : Item, Documentation { */ public void accept_all_children (Visitor visitor, bool filtered = true) { foreach (Vala.List children in per_type_children.get_values ()) { + if (this.parent == children[0]) { + continue; + } foreach (Node node in children) { if (node.do_document || !filtered) { node.accept (visitor); diff --git a/valadoc/tests/drivers/api-test.data.vapi b/valadoc/tests/drivers/api-test.data.vapi index 37871f012..c23ca2979 100644 --- a/valadoc/tests/drivers/api-test.data.vapi +++ b/valadoc/tests/drivers/api-test.data.vapi @@ -26,6 +26,7 @@ public errordomain TestErrDomGlobal { ERROR2; public static void static_method (); + public static void static_method_error () throws TestErrDomGlobal; } diff --git a/valadoc/tests/drivers/generic-api-test.vala b/valadoc/tests/drivers/generic-api-test.vala index 5d20405d6..ad99accfd 100644 --- a/valadoc/tests/drivers/generic-api-test.vala +++ b/valadoc/tests/drivers/generic-api-test.vala @@ -258,7 +258,7 @@ public static void test_erroromain_global (Api.ErrorDomain? err, Api.Package pkg Vala.List methods = err.get_children_by_type (Api.NodeType.STATIC_METHOD, false); - assert (methods.size == 1); + assert (methods.size == 2); Api.Method method = methods.get (0) as Api.Method; assert (method != null); -- cgit v1.2.1