[valadoc] libvaladoc: Add context check for @throws



commit ca801cceaa0d38103754d1c3e31505216baa89de
Author: Florian Brosch <flo brosch gmail com>
Date:   Sat Jul 21 16:45:50 2012 +0200

    libvaladoc: Add context check for @throws

 src/libvaladoc/taglets/tagletthrows.vala |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)
---
diff --git a/src/libvaladoc/taglets/tagletthrows.vala b/src/libvaladoc/taglets/tagletthrows.vala
index 986e797..4136624 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<Api.Node> 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);
 	}
 



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