]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
libvaladoc: Add context check for @throws
authorFlorian Brosch <flo.brosch@gmail.com>
Sat, 21 Jul 2012 14:45:50 +0000 (16:45 +0200)
committerFlorian Brosch <flo.brosch@gmail.com>
Sat, 21 Jul 2012 14:45:50 +0000 (16:45 +0200)
src/libvaladoc/taglets/tagletthrows.vala

index 986e797c9b170501cd9525fa564ae9c8ac6b9441..41366247500aa835b82011ead555d35fe7e15c5e 100644 (file)
@@ -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);
        }