Example usage for org.eclipse.jdt.core.dom TagElement TAG_INHERITDOC

List of usage examples for org.eclipse.jdt.core.dom TagElement TAG_INHERITDOC

Introduction

In this page you can find the example usage for org.eclipse.jdt.core.dom TagElement TAG_INHERITDOC.

Prototype

String TAG_INHERITDOC

To view the source code for org.eclipse.jdt.core.dom TagElement TAG_INHERITDOC.

Click Source Link

Document

Standard inline doc tag name (value ).

Usage

From source file:at.bestsolution.fxide.jdt.text.javadoc.JavadocContentAccess2.java

License:Open Source License

/**
 * Handle {@inheritDoc}./*from w w  w  .  ja  v a 2s.  c o  m*/
 *
 * @param node the node
 * @return <code>true</code> iff the node was an {&#64;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) {
        //TODO
        e.printStackTrace();
    }
    return false;
}

From source file:com.codenvy.ide.ext.java.server.javadoc.JavadocContentAccess2.java

License:Open Source License

/**
 * Handle {&#64;inheritDoc}.//from   w ww  .j  a va2s .c  om
 *
 * @param node
 *         the node
 * @return <code>true</code> iff the node was an {&#64;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();
            if (fragments.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 (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) {
        LOG.error(e.getMessage(), e);
    }
    return false;
}

From source file:org.eclipse.xtext.xbase.ui.hover.XbaseHoverDocumentationProvider.java

License:Open Source License

protected boolean handleInheritDoc(TagElement node) {
    if (!TagElement.TAG_INHERITDOC.equals(node.getTagName()))
        return false;
    // Not handled explicit for Xbase for now
    handleText(node.toString());/*w  ww. j a va2 s . c o m*/
    return true;
}