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

index 5a2797737cfeaca5fc0cbe6ed90509f060beb071..8a8e0640b83770baf178b41e105cf9071fbd7682 100644 (file)
@@ -31,7 +31,20 @@ public class Valadoc.Taglets.Return : InlineContent, Taglet, Block {
        }
 
        public override void check (Api.Tree api_root, Api.Node container, string file_path, ErrorReporter reporter, Settings settings) {
-               // TODO check for the existence of a return type
+               Api.TypeReference? type_ref = null;
+               if (container is Api.Method) {
+                       type_ref = ((Api.Method) container).return_type;
+               } else if (container is Api.Delegate) {
+                       type_ref = ((Api.Delegate) container).return_type;
+               } else if (container is Api.Signal) {
+                       type_ref = ((Api.Signal) container).return_type;
+               } else {
+                       reporter.simple_warning ("@return used outside method/delegate/signal context");
+               }
+
+               if (type_ref != null && type_ref.data_type == null) {
+                       reporter.simple_warning ("Return description declared for void function");
+               }
 
                base.check (api_root, container, file_path, reporter, settings);
        }