Search in sources :

Example 46 with TagElement

use of org.eclipse.jdt.core.dom.TagElement in project che by eclipse.

the class JavadocContentAccess2 method getReturnDescription.

CharSequence getReturnDescription() {
    if (fReturnDescription == null) {
        fReturnDescription = new StringBuffer();
        fBuf = fReturnDescription;
        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_RETURN.equals(tagName)) {
                handleContentElements(tag.fragments());
                break;
            }
        }
        fBuf = null;
    }
    return fReturnDescription.length() > 0 ? fReturnDescription : null;
}
Also used : TagElement(org.eclipse.jdt.core.dom.TagElement)

Example 47 with TagElement

use of org.eclipse.jdt.core.dom.TagElement in project che by eclipse.

the class JavadocContentAccess2 method handleParameterTags.

private void handleParameterTags(List<TagElement> tags, List<String> parameterNames, CharSequence[] parameterDescriptions) {
    if (tags.size() == 0 && containsOnlyNull(parameterNames))
        return;
    handleBlockTagTitle(JavaDocMessages.JavaDoc2HTMLTextReader_parameters_section);
    for (Iterator<TagElement> iter = tags.iterator(); iter.hasNext(); ) {
        TagElement tag = iter.next();
        fBuf.append(BlOCK_TAG_ENTRY_START);
        handleParamTag(tag);
        fBuf.append(BlOCK_TAG_ENTRY_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_ENTRY_START);
            fBuf.append(PARAM_NAME_START);
            fBuf.append(name);
            fBuf.append(PARAM_NAME_END);
            if (description != null)
                fBuf.append(description);
            fBuf.append(BlOCK_TAG_ENTRY_END);
        }
    }
}
Also used : TagElement(org.eclipse.jdt.core.dom.TagElement)

Example 48 with TagElement

use of org.eclipse.jdt.core.dom.TagElement in project che 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(JavaDocMessages.JavaDoc2HTMLTextReader_throws_section);
    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);
        }
    }
}
Also used : TagElement(org.eclipse.jdt.core.dom.TagElement)

Example 49 with TagElement

use of org.eclipse.jdt.core.dom.TagElement in project che 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;
}
Also used : SimpleName(org.eclipse.jdt.core.dom.SimpleName) TagElement(org.eclipse.jdt.core.dom.TagElement)

Example 50 with TagElement

use of org.eclipse.jdt.core.dom.TagElement in project che by eclipse.

the class JavadocContentAccess2 method getExceptionDescription.

CharSequence getExceptionDescription(String simpleName) {
    if (fMethod != null) {
        if (fExceptionDescriptions == null) {
            fExceptionDescriptions = new HashMap<String, StringBuffer>();
        } 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;
}
Also used : TagElement(org.eclipse.jdt.core.dom.TagElement) SimpleName(org.eclipse.jdt.core.dom.SimpleName) Name(org.eclipse.jdt.core.dom.Name)

Aggregations

TagElement (org.eclipse.jdt.core.dom.TagElement)76 ASTNode (org.eclipse.jdt.core.dom.ASTNode)36 Javadoc (org.eclipse.jdt.core.dom.Javadoc)28 TextElement (org.eclipse.jdt.core.dom.TextElement)23 AST (org.eclipse.jdt.core.dom.AST)20 ASTRewrite (org.eclipse.jdt.core.dom.rewrite.ASTRewrite)19 MethodDeclaration (org.eclipse.jdt.core.dom.MethodDeclaration)18 SimpleName (org.eclipse.jdt.core.dom.SimpleName)17 Type (org.eclipse.jdt.core.dom.Type)17 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)16 ImportRewriteContext (org.eclipse.jdt.core.dom.rewrite.ImportRewrite.ImportRewriteContext)16 CompilationUnit (org.eclipse.jdt.core.dom.CompilationUnit)14 ImportRewrite (org.eclipse.jdt.core.dom.rewrite.ImportRewrite)14 ContextSensitiveImportRewriteContext (org.eclipse.jdt.internal.corext.codemanipulation.ContextSensitiveImportRewriteContext)14 BodyDeclaration (org.eclipse.jdt.core.dom.BodyDeclaration)11 PrimitiveType (org.eclipse.jdt.core.dom.PrimitiveType)11 ListRewrite (org.eclipse.jdt.core.dom.rewrite.ListRewrite)11 ArrayList (java.util.ArrayList)10 List (java.util.List)9 ITypeBinding (org.eclipse.jdt.core.dom.ITypeBinding)8