Search in sources :

Example 41 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 42 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 43 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 44 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 45 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)59 ASTNode (org.eclipse.jdt.core.dom.ASTNode)29 Javadoc (org.eclipse.jdt.core.dom.Javadoc)25 AST (org.eclipse.jdt.core.dom.AST)17 TextElement (org.eclipse.jdt.core.dom.TextElement)16 MethodDeclaration (org.eclipse.jdt.core.dom.MethodDeclaration)15 ASTRewrite (org.eclipse.jdt.core.dom.rewrite.ASTRewrite)15 Type (org.eclipse.jdt.core.dom.Type)14 ImportRewriteContext (org.eclipse.jdt.core.dom.rewrite.ImportRewrite.ImportRewriteContext)14 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)13 CompilationUnit (org.eclipse.jdt.core.dom.CompilationUnit)12 ImportRewrite (org.eclipse.jdt.core.dom.rewrite.ImportRewrite)12 SimpleName (org.eclipse.jdt.core.dom.SimpleName)11 ListRewrite (org.eclipse.jdt.core.dom.rewrite.ListRewrite)11 BodyDeclaration (org.eclipse.jdt.core.dom.BodyDeclaration)8 PrimitiveType (org.eclipse.jdt.core.dom.PrimitiveType)8 SingleVariableDeclaration (org.eclipse.jdt.core.dom.SingleVariableDeclaration)7 ContextSensitiveImportRewriteContext (org.eclipse.jdt.internal.corext.codemanipulation.ContextSensitiveImportRewriteContext)7 ContextSensitiveImportRewriteContext (org.eclipse.jdt.ls.core.internal.corext.codemanipulation.ContextSensitiveImportRewriteContext)7 ArrayList (java.util.ArrayList)6