use of org.eclipse.jdt.core.dom.TagElement in project eclipse.jdt.ls by eclipse.
the class JavadocContentAccess2 method handleInheritDoc.
/**
* Handle {@inheritDoc}.
*
* @param node
* the node
* @return <code>true</code> iff the node was an {@inheritDoc} node and has
* been handled
*/
private boolean handleInheritDoc(TagElement node) {
if (!TagElement.TAG_INHERITDOC.equals(node.getTagName())) {
return false;
}
try {
if (fMethod == null) {
return false;
}
TagElement blockTag = (TagElement) node.getParent();
String blockTagName = blockTag.getTagName();
if (blockTagName == null) {
CharSequence inherited = fJavadocLookup.getInheritedMainDescription(fMethod);
return handleInherited(inherited);
} else if (TagElement.TAG_PARAM.equals(blockTagName)) {
List<? extends ASTNode> fragments = blockTag.fragments();
int size = fragments.size();
if (size > 0) {
Object first = fragments.get(0);
if (first instanceof SimpleName) {
String name = ((SimpleName) first).getIdentifier();
String[] parameterNames = fMethod.getParameterNames();
for (int i = 0; i < parameterNames.length; i++) {
if (name.equals(parameterNames[i])) {
CharSequence inherited = fJavadocLookup.getInheritedParamDescription(fMethod, i);
return handleInherited(inherited);
}
}
} else if (size > 2 && first instanceof TextElement) {
String firstText = ((TextElement) first).getText();
if ("<".equals(firstText)) {
// $NON-NLS-1$
Object second = fragments.get(1);
Object third = fragments.get(2);
if (second instanceof SimpleName && third instanceof TextElement) {
String thirdText = ((TextElement) third).getText();
if (">".equals(thirdText)) {
// $NON-NLS-1$
String name = ((SimpleName) second).getIdentifier();
ITypeParameter[] typeParameters = fMethod.getTypeParameters();
for (int i = 0; i < typeParameters.length; i++) {
ITypeParameter typeParameter = typeParameters[i];
if (name.equals(typeParameter.getElementName())) {
CharSequence inherited = fJavadocLookup.getInheritedTypeParamDescription(fMethod, i);
return handleInherited(inherited);
}
}
}
}
}
}
}
} else if (TagElement.TAG_RETURN.equals(blockTagName)) {
CharSequence inherited = fJavadocLookup.getInheritedReturnDescription(fMethod);
return handleInherited(inherited);
} else if (TagElement.TAG_THROWS.equals(blockTagName) || TagElement.TAG_EXCEPTION.equals(blockTagName)) {
List<? extends ASTNode> fragments = blockTag.fragments();
if (fragments.size() > 0) {
Object first = fragments.get(0);
if (first instanceof Name) {
String name = ASTNodes.getSimpleNameIdentifier((Name) first);
CharSequence inherited = fJavadocLookup.getInheritedExceptionDescription(fMethod, name);
return handleInherited(inherited);
}
}
}
} catch (JavaModelException e) {
}
return false;
}
use of org.eclipse.jdt.core.dom.TagElement in project eclipse.jdt.ls by eclipse.
the class JavadocContentAccess2 method getExceptionDescription.
CharSequence getExceptionDescription(String simpleName) {
if (fMethod != null) {
if (fExceptionDescriptions == null) {
fExceptionDescriptions = new HashMap<>();
} else {
StringBuffer description = fExceptionDescriptions.get(simpleName);
if (description != null) {
return description.length() > 0 ? description : null;
}
}
StringBuffer description = new StringBuffer();
fExceptionDescriptions.put(simpleName, description);
fBuf = description;
fLiteralContent = 0;
List<TagElement> tags = fJavadoc.tags();
for (Iterator<TagElement> iter = tags.iterator(); iter.hasNext(); ) {
TagElement tag = iter.next();
String tagName = tag.getTagName();
if (TagElement.TAG_THROWS.equals(tagName) || TagElement.TAG_EXCEPTION.equals(tagName)) {
List<? extends ASTNode> fragments = tag.fragments();
if (fragments.size() > 0) {
Object first = fragments.get(0);
if (first instanceof Name) {
String name = ASTNodes.getSimpleNameIdentifier((Name) first);
if (name.equals(simpleName)) {
if (fragments.size() > 1) {
handleContentElements(fragments.subList(1, fragments.size()));
}
break;
}
}
}
}
}
fBuf = null;
return description.length() > 0 ? description : null;
}
return null;
}
use of org.eclipse.jdt.core.dom.TagElement in project eclipse.jdt.ls by eclipse.
the class JavadocContentAccess2 method handleParameterTags.
private void handleParameterTags(List<TagElement> tags, List<String> parameterNames, CharSequence[] parameterDescriptions, boolean isTypeParameters) {
if (tags.size() == 0 && containsOnlyNull(parameterNames)) {
return;
}
String tagTitle = isTypeParameters ? JavaDoc2HTMLTextReader_type_parameters_section : JavaDoc2HTMLTextReader_parameters_section;
handleBlockTagTitle(tagTitle);
for (Iterator<TagElement> iter = tags.iterator(); iter.hasNext(); ) {
TagElement tag = iter.next();
fBuf.append(BLOCK_TAG_START);
fBuf.append(BlOCK_TAG_ENTRY_START);
handleParamTag(tag);
fBuf.append(BlOCK_TAG_ENTRY_END);
fBuf.append(BLOCK_TAG_END);
}
for (int i = 0; i < parameterDescriptions.length; i++) {
CharSequence description = parameterDescriptions[i];
String name = parameterNames.get(i);
if (name != null) {
fBuf.append(BLOCK_TAG_START);
fBuf.append(BlOCK_TAG_ENTRY_START);
fBuf.append(PARAM_NAME_START);
if (isTypeParameters) {
// $NON-NLS-1$
fBuf.append("<");
}
fBuf.append(name);
if (isTypeParameters) {
// $NON-NLS-1$
fBuf.append(">");
}
fBuf.append(PARAM_NAME_END);
if (description != null) {
fBuf.append(description);
}
fBuf.append(BlOCK_TAG_ENTRY_END);
fBuf.append(BLOCK_TAG_END);
}
}
fBuf.append(BlOCK_TAG_ENTRY_END);
}
use of org.eclipse.jdt.core.dom.TagElement in project eclipse.jdt.ls by eclipse.
the class JavadocContentAccess2 method getInheritedParamDescription.
CharSequence getInheritedParamDescription(int paramIndex) throws JavaModelException {
if (fMethod != null) {
String[] parameterNames = fMethod.getParameterNames();
if (fParamDescriptions == null) {
fParamDescriptions = new StringBuffer[parameterNames.length];
} else {
StringBuffer description = fParamDescriptions[paramIndex];
if (description != null) {
return description.length() > 0 ? description : null;
}
}
StringBuffer description = new StringBuffer();
fParamDescriptions[paramIndex] = description;
fBuf = description;
fLiteralContent = 0;
String paramName = parameterNames[paramIndex];
List<TagElement> tags = fJavadoc.tags();
for (Iterator<TagElement> iter = tags.iterator(); iter.hasNext(); ) {
TagElement tag = iter.next();
String tagName = tag.getTagName();
if (TagElement.TAG_PARAM.equals(tagName)) {
List<? extends ASTNode> fragments = tag.fragments();
if (fragments.size() > 0) {
Object first = fragments.get(0);
if (first instanceof SimpleName) {
String name = ((SimpleName) first).getIdentifier();
if (name.equals(paramName)) {
handleContentElements(fragments.subList(1, fragments.size()));
break;
}
}
}
}
}
fBuf = null;
return description.length() > 0 ? description : null;
}
return null;
}
use of org.eclipse.jdt.core.dom.TagElement in project eclipse.jdt.ls by eclipse.
the class JavadocContentAccess2 method handleExceptionTags.
private void handleExceptionTags(List<TagElement> tags, List<String> exceptionNames, CharSequence[] exceptionDescriptions) {
if (tags.size() == 0 && containsOnlyNull(exceptionNames)) {
return;
}
handleBlockTagTitle(JavaDoc2HTMLTextReader_throws_section);
fBuf.append(BLOCK_TAG_START);
for (Iterator<TagElement> iter = tags.iterator(); iter.hasNext(); ) {
TagElement tag = iter.next();
fBuf.append(BlOCK_TAG_ENTRY_START);
handleThrowsTag(tag);
fBuf.append(BlOCK_TAG_ENTRY_END);
}
for (int i = 0; i < exceptionDescriptions.length; i++) {
CharSequence description = exceptionDescriptions[i];
String name = exceptionNames.get(i);
if (name != null) {
fBuf.append(BlOCK_TAG_ENTRY_START);
handleLink(Collections.singletonList(fJavadoc.getAST().newSimpleName(name)));
if (description != null) {
fBuf.append(JavaElementLabels.CONCAT_STRING);
fBuf.append(description);
}
fBuf.append(BlOCK_TAG_ENTRY_END);
}
}
fBuf.append(BLOCK_TAG_END);
fBuf.append(BlOCK_TAG_ENTRY_END);
}
Aggregations