use of com.sun.source.doctree.ParamTree in project cxf by apache.
the class DumpJavaDoc method run.
@Override
public boolean run(DocletEnvironment docEnv) {
final Elements utils = docEnv.getElementUtils();
final DocTrees docTrees = docEnv.getDocTrees();
try (OutputStream os = Files.newOutputStream(Paths.get(dumpFileName))) {
final Properties javaDocMap = new Properties();
for (Element element : docEnv.getIncludedElements()) {
if (element.getKind() == ElementKind.CLASS) {
final TypeElement classDoc = (TypeElement) element;
final DocCommentTree classCommentTree = docTrees.getDocCommentTree(classDoc);
if (classCommentTree != null) {
javaDocMap.put(classDoc.toString(), getAllComments(classCommentTree.getFullBody()));
}
for (Element member : classDoc.getEnclosedElements()) {
// Skip all non-public methods
if (!member.getModifiers().contains(Modifier.PUBLIC)) {
continue;
}
if (member.getKind() == ElementKind.METHOD) {
final ExecutableElement method = (ExecutableElement) member;
final DocCommentTree methodCommentTree = docTrees.getDocCommentTree(method);
final String qualifiedName = utils.getBinaryName(classDoc) + "." + method.getSimpleName();
if (methodCommentTree == null) {
javaDocMap.put(qualifiedName, "");
} else {
javaDocMap.put(qualifiedName, getAllComments(methodCommentTree.getFullBody()));
for (DocTree tree : methodCommentTree.getBlockTags()) {
if (tree.getKind() == DocTree.Kind.RETURN) {
final ReturnTree returnTree = (ReturnTree) tree;
javaDocMap.put(qualifiedName + ".returnCommentTag", getAllComments(returnTree.getDescription()));
} else if (tree.getKind() == DocTree.Kind.PARAM) {
final ParamTree paramTree = (ParamTree) tree;
final int index = getParamIndex(method, paramTree);
if (index >= 0) {
javaDocMap.put(qualifiedName + ".paramCommentTag." + index, getAllComments(paramTree.getDescription()));
}
}
}
}
}
}
}
}
javaDocMap.store(os, "");
os.flush();
} catch (final IOException ex) {
reporter.print(Diagnostic.Kind.ERROR, ex.getMessage());
}
return true;
}
Aggregations