Example usage for org.eclipse.jdt.core IPackageDeclaration getAncestor

List of usage examples for org.eclipse.jdt.core IPackageDeclaration getAncestor

Introduction

In this page you can find the example usage for org.eclipse.jdt.core IPackageDeclaration getAncestor.

Prototype

IJavaElement getAncestor(int ancestorType);

Source Link

Document

Returns this Java element or the first ancestor of this element that has the given type.

Usage

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

License:Open Source License

/**
 * Returns the Javadoc for a PackageDeclaration.
 *
 * @param packageDeclaration the Java element whose Javadoc has to be retrieved
 * @return the package documentation in HTML format or <code>null</code> if there is no
 *         associated Javadoc//from w ww . j a  v  a 2  s. c o m
 * @throws CoreException if the Java element does not exists or an exception occurs while
 *             accessing the file containing the package Javadoc
 * @since 3.9
 */
public static String getHTMLContent(IPackageDeclaration packageDeclaration) throws CoreException {
    IJavaElement element = packageDeclaration.getAncestor(IJavaElement.PACKAGE_FRAGMENT);
    if (element instanceof IPackageFragment) {
        return getHTMLContent((IPackageFragment) element);
    }
    return null;
}

From source file:org.eclipse.che.jdt.javadoc.JavadocContentAccess2.java

License:Open Source License

/**
 * Returns the Javadoc for a PackageDeclaration.
 *
 * @param packageDeclaration the Java element whose Javadoc has to be retrieved
 * @param urlPrefix//from   w  w w .j  a  v a2s.  c  o  m
 * @return the package documentation in HTML format or <code>null</code> if there is no
 *         associated Javadoc
 * @throws CoreException if the Java element does not exists or an exception occurs while
 *             accessing the file containing the package Javadoc
 * @since 3.9
 */
public static String getHTMLContent(IPackageDeclaration packageDeclaration, String urlPrefix)
        throws CoreException {
    IJavaElement element = packageDeclaration.getAncestor(IJavaElement.PACKAGE_FRAGMENT);
    if (element instanceof IPackageFragment) {
        return getHTMLContent((IPackageFragment) element, urlPrefix);
    }
    return null;
}