try
{
ClassDoc classDoc = docSpecification.getClassDoc();
MethodDoc methodDoc = docSpecification.getMethodDoc();
JCClassDecl classImplementation = docSpecification.getClassImplementation();
JavaFileParser parser = docSpecification.getParser();
String methodName = methodDoc.name();
Parameter[] parameters = methodDoc.parameters();
String[] parameterClassnames = new String[parameters.length];
for (int i = 0;i< parameters.length; i++)
parameterClassnames[i] = parameters[i].typeName();
//handle only methods that are defined in the source code and not generated by the compiler.
if ( !(
methodDoc.isAbstract() ||
methodDoc.isSynthetic() ||
(classDoc.isEnum() && "values".equals(methodName) ) ||
(classDoc.enumConstants() != null && (classDoc.enumConstants().length > 0) && "values".equals(methodName) )
))
{
/*
System.out.println("class modifiers "+ classDoc.modifiers());
System.out.println("class "+ classDoc.name()+" is enum:" + classDoc.isEnum());
System.out.println("enum constants " + classDoc.enumConstants());
if (classDoc.enumConstants() != null)
System.out.println("enum constants " + classDoc.enumConstants().length);
System.out.println("method " + methodName + " is synthetic:" + methodDoc.isSynthetic());
*/
JCMethodDecl method = null;
try
{
method = parser.getMethod(classImplementation, methodName, parameterClassnames);
}
catch (Exception ex)
{
ex.printStackTrace(); //there are currently some problems with enums so that excpetion can occur in the generated values method
}
if (method != null)
{
String methodBody = parser.getBodySourcecode(method);
if ( (methodBody != null) && ! docSpecification.hasTag(methodDoc, "@"+ "return") && methodBody.contains("@return"))
{
methodDoc.setRawCommentText( methodDoc.getRawCommentText() + "\n" + GLUEBOOSTER_PREFIX_TEXT + " return");
}