[valadoc] libvaladoc: Add context check for @return



commit 64974b8bb083d41fb37ec54f6d074a51a697f479
Author: Florian Brosch <flo brosch gmail com>
Date:   Sat Jul 21 16:47:02 2012 +0200

    libvaladoc: Add context check for @return

 src/libvaladoc/taglets/tagletreturn.vala |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)
---
diff --git a/src/libvaladoc/taglets/tagletreturn.vala b/src/libvaladoc/taglets/tagletreturn.vala
index 5a27977..8a8e064 100644
--- a/src/libvaladoc/taglets/tagletreturn.vala
+++ b/src/libvaladoc/taglets/tagletreturn.vala
@@ -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);
 	}



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