ehatcher 02/03/02 17:49:54
Modified: proposal/xdocs/src/org/apache/tools/ant/xdoclet
AntSubTask.java
Log:
dramatically improved the "smarts" of finding real tasks.
defaults.properties generation is just about there, which is sort of the litmus
test to ensure that the right classes are being processed.
Revision Changes Path
1.4 +35 -3
jakarta-ant/proposal/xdocs/src/org/apache/tools/ant/xdoclet/AntSubTask.java
Index: AntSubTask.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/xdocs/src/org/apache/tools/ant/xdoclet/AntSubTask.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- AntSubTask.java 28 Feb 2002 03:45:09 -0000 1.3
+++ AntSubTask.java 3 Mar 2002 01:49:54 -0000 1.4
@@ -56,8 +56,10 @@
import com.sun.javadoc.ClassDoc;
import com.sun.javadoc.MethodDoc;
import com.sun.javadoc.PackageDoc;
+import com.sun.javadoc.Tag;
import xdoclet.TemplateSubTask;
import xdoclet.XDocletException;
+import xdoclet.XDocletTagSupport;
import xdoclet.tags.PackageTagsHandler;
import java.io.File;
@@ -88,7 +90,7 @@
/**
* @todo pull out to utility method
- * @todo add more logic (like execute method signature)
+ * @todo revisit deprecated removal - perhaps need an @ant.task
ignore="true"?
*/
public static final boolean isAntTask(ClassDoc clazz) {
if (clazz.isAbstract()) {
@@ -100,14 +102,44 @@
return false;
}
+ // remove deprecated tasks (controversial!)
+ Tag[] tags = clazz.tags();
+ for (int i=0; i < tags.length; i++) {
+ if ("@deprecated".equals(tags[i].name())) {
+ return false;
+ }
+ }
+
+ if (hasExecuteMethod(clazz)) {
+ return true;
+ }
+
+ return false;
+ }
+
+ private static boolean hasExecuteMethod (ClassDoc clazz) {
+ if (clazz == null) {
+ return false;
+ }
+
+ // It ain't a task if we've climbed back to Task itself
+ if ("org.apache.tools.ant.Task".equals(clazz.qualifiedName())) {
+ return false;
+ }
+
+ // need to check that only runtime exceptions are thrown?
MethodDoc[] methods = clazz.methods();
for (int i = 0; i < methods.length; i++) {
if ("execute".equals(methods[i].name())) {
- return true;
+ if (methods[i].parameters().length == 0) {
+ if (methods[i].returnType().typeName().equals("void")) {
+ return true;
+ }
+ }
}
}
- return false;
+ return hasExecuteMethod(clazz.superclass());
}
/**
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>