From: Florian Brosch Date: Sat, 21 Jul 2012 14:45:50 +0000 (+0200) Subject: libvaladoc: Add context check for @throws X-Git-Tag: 0.37.1~3^2~191 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ca801cceaa0d38103754d1c3e31505216baa89de;p=thirdparty%2Fvala.git libvaladoc: Add context check for @throws --- diff --git a/src/libvaladoc/taglets/tagletthrows.vala b/src/libvaladoc/taglets/tagletthrows.vala index 986e797c9..413662475 100644 --- a/src/libvaladoc/taglets/tagletthrows.vala +++ b/src/libvaladoc/taglets/tagletthrows.vala @@ -37,13 +37,25 @@ public class Valadoc.Taglets.Throws : InlineContent, Taglet, Block { } public override void check (Api.Tree api_root, Api.Node container, string file_path, ErrorReporter reporter, Settings settings) { + // context check: + if (container is Api.Method == false && container is Api.Delegate == false) { + reporter.simple_warning ("@throws used outside method/delegate context"); + base.check (api_root, container, file_path, reporter, settings); + return ; + } + + + // type check: error_domain = api_root.search_symbol_str (container, error_domain_name); if (error_domain == null) { // TODO use ContentElement's source reference - reporter.simple_error ("%s does not exist", error_domain_name); + reporter.simple_error ("%s: %s does not exist", container.get_full_name (), error_domain_name); + base.check (api_root, container, file_path, reporter, settings); + return ; } + // Check if the method is allowed to throw the given type: Gee.List exceptions = container.get_children_by_types ({Api.NodeType.ERROR_DOMAIN, Api.NodeType.CLASS}, false); bool report_warning = true; foreach (Api.Node exception in exceptions) { @@ -53,10 +65,9 @@ public class Valadoc.Taglets.Throws : InlineContent, Taglet, Block { } } if (report_warning) { - reporter.simple_warning ("%s does not exist in exception list", error_domain_name); + reporter.simple_warning ("%s: @throws: %s does not exist in exception list", container.get_full_name (), error_domain_name); } - base.check (api_root, container, file_path, reporter, settings); }