Wrote a custom doclet using the [Doclet API|http://java.sun.com/j2se/1.3/docs/tooldocs/javadoc/doclet/index.html ].
The purpose for the doclet is to load Java source files and create stubs (which are identical Java source files but do not contain any method implementation details).
Instead, the method implementation details need to be replaced with blank lines...
public class MyDoclet {
private static String TAB = "\t";
public static boolean start(RootDoc root) {
ClassDoc[] classes = root.classes();
// Parse through class or interface
for (ClassDoc clazz : classes) {
Type superClass = clazz.superclassType();
// Print Methods
MethodDoc[] methods = clazz.methods();
for (MethodDoc method : methods) {
Parameter[] parameters = method.parameters();
println();
if (!method.isPrivate()) {
print(TAB + method.modifiers() + " "
+ method.returnType().simpleTypeName() + " " + method.name());
print("(");
for (int i=0; i < parameters.length; i++) {
Parameter parameter = (Parameter) parameters;
print(parameter.type().simpleTypeName() + " " + parameter.name());
if (i != parameters.length - 1) {
print(", ");
}
}
print(")");
println(" {");
println("\n");
println(TAB + "}");
}
}
}
return true;
}
}
As one can see, I am just creating the method and placing the opening and closing curly braces (along with a new \n line escape sequence, in between).
Am not really that familiar with the Doclet API...
Question(s):
(1) What is the best way to figure out how many lines of code are inside each method and then use a for loop to insert the exact same number of blank lines inside the methods?
(2) Is there a way to do it using the com.sun.javadoc.SourcePosition.line() method?
Would really appreciate it if someone could help me because this is an important requirement (hence the 10 Duke Stars).
Happy coding to all,
Mike