private static String getArgument(TagElement curr) { List<? extends ASTNode> fragments = curr.fragments(); if (!fragments.isEmpty()) { Object first = fragments.get(0); if (first instanceof Name) { return ASTNodes.getSimpleNameIdentifier((Name) first); } else if (first instanceof TextElement && TagElement.TAG_PARAM.equals(curr.getTagName())) { String text = ((TextElement) first).getText(); if ("<".equals(text) && fragments.size() >= 3) { // $NON-NLS-1$ Object second = fragments.get(1); Object third = fragments.get(2); if (second instanceof Name && third instanceof TextElement && ">".equals(((TextElement) third).getText())) { // $NON-NLS-1$ return '<' + ASTNodes.getSimpleNameIdentifier((Name) second) + '>'; } } else if (text.startsWith(String.valueOf('<')) && text.endsWith(String.valueOf('>')) && text.length() > 2) { return text.substring(1, text.length() - 1); } } } return null; }
public static TagElement findParamTag(Javadoc javadoc, String arg) { List<TagElement> tags = javadoc.tags(); int nTags = tags.size(); for (int i = 0; i < nTags; i++) { TagElement curr = tags.get(i); String currName = curr.getTagName(); if (TagElement.TAG_PARAM.equals(currName)) { String argument = getArgument(curr); if (arg.equals(argument)) { return curr; } } } return null; }