use of com.sun.source.doctree.IdentifierTree in project j2objc by google.
the class JavadocConverter method visitParam.
@Override
public Void visitParam(ParamTree node, TagElement tag) {
IdentifierTree identifier = node.getName();
if (identifier == null || node.isTypeParameter()) {
return null;
}
List<? extends VariableElement> params = element instanceof ExecutableElement ? ((ExecutableElement) element).getParameters() : Collections.emptyList();
tag.setTagKind(TagElement.TagKind.PARAM);
String name = identifier.toString();
VariableElement param = null;
for (VariableElement p : params) {
if (name.equals(p.getSimpleName().toString())) {
param = p;
break;
}
}
// param will be null if the @param tag refers to a nonexistent parameter.
TreeNode nameNode = param != null ? new SimpleName(param) : new SimpleName(name);
setPos(identifier, nameNode);
tag.addFragment(nameNode);
scan(node.getDescription(), tag);
int lastEnd = nameNode.getStartPosition();
for (TreeNode fragment : tag.getFragments()) {
// TODO(tball): remove and fix JavadocGenerator after javac switch.
if (fragment.getKind() == TreeNode.Kind.TEXT_ELEMENT) {
TextElement text = (TextElement) fragment;
text.setText(" " + text.getText());
text.setSourceRange(text.getStartPosition(), text.getLength() + 1);
}
int thisEnd = lastEnd + fragment.getLength();
setPos(fragment, lastEnd, thisEnd);
lastEnd = thisEnd;
}
setPos(tag, pos(node), endPos(node));
tag.setLineNumber(nameNode.getLineNumber());
return null;
}
Aggregations