当前位置: 首页>>代码示例>>Java>>正文


Java IMember.getAncestor方法代码示例

本文整理汇总了Java中org.eclipse.jdt.core.IMember.getAncestor方法的典型用法代码示例。如果您正苦于以下问题:Java IMember.getAncestor方法的具体用法?Java IMember.getAncestor怎么用?Java IMember.getAncestor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jdt.core.IMember的用法示例。


在下文中一共展示了IMember.getAncestor方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isVisibleInHierarchy

import org.eclipse.jdt.core.IMember; //导入方法依赖的package包/类
/**
 * Evaluates if a member in the focus' element hierarchy is visible from elements in a package.
 *
 * @param member The member to test the visibility for
 * @param pack The package of the focus element focus
 * @return returns <code>true</code> if the member is visible from the package
 * @throws JavaModelException thrown when the member can not be accessed
 */
public static boolean isVisibleInHierarchy(IMember member, IPackageFragment pack)
    throws JavaModelException {
  int type = member.getElementType();
  if (type == IJavaElement.INITIALIZER
      || (type == IJavaElement.METHOD
          && member.getElementName().startsWith("<"))) { // $NON-NLS-1$
    return false;
  }

  int otherflags = member.getFlags();

  IType declaringType = member.getDeclaringType();
  if (Flags.isPublic(otherflags)
      || Flags.isProtected(otherflags)
      || (declaringType != null && isInterfaceOrAnnotation(declaringType))) {
    return true;
  } else if (Flags.isPrivate(otherflags)) {
    return false;
  }

  IPackageFragment otherpack =
      (IPackageFragment) member.getAncestor(IJavaElement.PACKAGE_FRAGMENT);
  return (pack != null && pack.equals(otherpack));
}
 
开发者ID:eclipse,项目名称:che,代码行数:33,代码来源:JavaModelUtil.java

示例2: isVisible

import org.eclipse.jdt.core.IMember; //导入方法依赖的package包/类
/**
 * Evaluates if a member (possible from another package) is visible from elements in a package.
 *
 * @param member The member to test the visibility for
 * @param pack The package in focus
 * @return returns <code>true</code> if the member is visible from the package
 * @throws JavaModelException thrown when the member can not be accessed
 */
public static boolean isVisible(IMember member, IPackageFragment pack) throws JavaModelException {

  int type = member.getElementType();
  if (type == IJavaElement.INITIALIZER
      || (type == IJavaElement.METHOD
          && member.getElementName().startsWith("<"))) { // $NON-NLS-1$
    return false;
  }

  int otherflags = member.getFlags();
  IType declaringType = member.getDeclaringType();
  if (Flags.isPublic(otherflags)
      || (declaringType != null && isInterfaceOrAnnotation(declaringType))) {
    return true;
  } else if (Flags.isPrivate(otherflags)) {
    return false;
  }

  IPackageFragment otherpack =
      (IPackageFragment) member.getAncestor(IJavaElement.PACKAGE_FRAGMENT);
  return (pack != null && otherpack != null && isSamePackage(pack, otherpack));
}
 
开发者ID:eclipse,项目名称:che,代码行数:31,代码来源:JavaModelUtil.java

示例3: getJavadoc

import org.eclipse.jdt.core.IMember; //导入方法依赖的package包/类
private String getJavadoc(IMember element) {
  StringBuffer buffer = new StringBuffer();
  boolean hasContents = false;
  if (element instanceof IPackageFragment || element instanceof IMember) {
    HTMLPrinter.addSmallHeader(buffer, getInfoText(element, element.getTypeRoot(), true));
    buffer.append("<br>"); // $NON-NLS-1$
    addAnnotations(buffer, element, element.getTypeRoot(), null);
    Reader reader = null;
    try {
      String content =
          element instanceof IMember
              ? JavadocContentAccess2.getHTMLContent(element, true, baseHref)
              : null; // JavadocContentAccess2.getHTMLContent((IPackageFragment)element);
      IPackageFragmentRoot root =
          (IPackageFragmentRoot) element.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
      if (content != null) {
        reader = new StringReader(content);
      } else {
        String explanationForMissingJavadoc =
            JavaDocLocations.getExplanationForMissingJavadoc(element, root);
        if (explanationForMissingJavadoc != null)
          reader = new StringReader(explanationForMissingJavadoc);
      }
    } catch (CoreException ex) {
      reader = new StringReader(JavaDocLocations.handleFailedJavadocFetch(ex));
    }

    if (reader != null) {
      HTMLPrinter.addParagraph(buffer, reader);
    }
    hasContents = true;
  }

  if (!hasContents) return null;

  if (buffer.length() > 0) {
    HTMLPrinter.insertPageProlog(buffer, 0, getStyleSheet());
    HTMLPrinter.addPageEpilog(buffer);
    return buffer.toString();
  }

  return null;
}
 
开发者ID:eclipse,项目名称:che,代码行数:44,代码来源:JavadocFinder.java


注:本文中的org.eclipse.jdt.core.IMember.getAncestor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。