本文整理汇总了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));
}
示例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));
}
示例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;
}