本文整理汇总了Java中org.eclipse.jdt.core.IMember.getFlags方法的典型用法代码示例。如果您正苦于以下问题:Java IMember.getFlags方法的具体用法?Java IMember.getFlags怎么用?Java IMember.getFlags使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.IMember
的用法示例。
在下文中一共展示了IMember.getFlags方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: appendFlags
import org.eclipse.jdt.core.IMember; //导入方法依赖的package包/类
protected void appendFlags(final IMember member) throws JavaModelException {
if (member instanceof IAnnotatable)
for (IAnnotation annotation : ((IAnnotatable) member).getAnnotations()) {
appendAnnotation(annotation);
}
int flags = member.getFlags();
final int kind = member.getElementType();
if (kind == IJavaElement.TYPE) {
flags &= ~Flags.AccSuper;
final IType type = (IType) member;
if (!type.isMember()) flags &= ~Flags.AccPrivate;
if (Flags.isEnum(flags)) flags &= ~Flags.AccAbstract;
}
if (Flags.isEnum(flags)) flags &= ~Flags.AccFinal;
if (kind == IJavaElement.METHOD) {
flags &= ~Flags.AccVarargs;
flags &= ~Flags.AccBridge;
}
if (flags != 0) fBuffer.append(Flags.toString(flags));
}
示例2: 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));
}
示例3: 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));
}
示例4: isVisibleMember
import org.eclipse.jdt.core.IMember; //导入方法依赖的package包/类
static boolean isVisibleMember(IMember member) throws JavaModelException {
int f = member.getFlags();
IType jType = member.getDeclaringType();
return
jType.getPackageFragment().isDefaultPackage() && (Flags.isPackageDefault(f) || Flags.isProtected(f) || Flags.isPublic(f))
||
Flags.isPublic(f);
}
示例5: isAbstract
import org.eclipse.jdt.core.IMember; //导入方法依赖的package包/类
public static boolean isAbstract(IMember member) throws JavaModelException {
int flags = member.getFlags();
if (!member.isBinary() && isInterfaceOrAnnotationMethod(member)) {
return !Flags.isStatic(flags) && !Flags.isDefaultMethod(flags);
}
return Flags.isAbstract(flags);
}
示例6: adjustIncomingVisibility
import org.eclipse.jdt.core.IMember; //导入方法依赖的package包/类
/**
* Adjusts the visibility of the specified member.
*
* @param element the "source" point from which to calculate the visibility
* @param referencedMovedElement the moved element which may be adjusted in visibility
* @param monitor the progress monitor to use
* @throws JavaModelException if the visibility adjustment could not be computed
*/
private void adjustIncomingVisibility(
final IJavaElement element, IMember referencedMovedElement, final IProgressMonitor monitor)
throws JavaModelException {
final ModifierKeyword threshold =
getVisibilityThreshold(element, referencedMovedElement, monitor);
int flags = referencedMovedElement.getFlags();
IType declaring = referencedMovedElement.getDeclaringType();
if (declaring != null && declaring.isInterface()
|| referencedMovedElement instanceof IField
&& Flags.isEnum(referencedMovedElement.getFlags())) return;
if (hasLowerVisibility(flags, threshold == null ? Modifier.NONE : threshold.toFlagValue())
&& needsVisibilityAdjustment(referencedMovedElement, threshold))
fAdjustments.put(
referencedMovedElement,
new IncomingMemberVisibilityAdjustment(
referencedMovedElement,
threshold,
RefactoringStatus.createStatus(
fVisibilitySeverity,
Messages.format(
getMessage(referencedMovedElement),
new String[] {getLabel(referencedMovedElement), getLabel(threshold)}),
JavaStatusContext.create(referencedMovedElement),
null,
RefactoringStatusEntry.NO_CODE,
null)));
}
示例7: appendMembers
import org.eclipse.jdt.core.IMember; //导入方法依赖的package包/类
protected void appendMembers(final IType type, final IProgressMonitor monitor)
throws JavaModelException {
try {
monitor.beginTask(RefactoringCoreMessages.StubCreationOperation_creating_type_stubs, 1);
final IJavaElement[] children = type.getChildren();
for (int index = 0; index < children.length; index++) {
final IMember child = (IMember) children[index];
final int flags = child.getFlags();
final boolean isPrivate = Flags.isPrivate(flags);
final boolean isDefault = !Flags.isPublic(flags) && !Flags.isProtected(flags) && !isPrivate;
final boolean stub = fStubInvisible || (!isPrivate && !isDefault);
if (child instanceof IType) {
if (stub) appendTypeDeclaration((IType) child, new SubProgressMonitor(monitor, 1));
} else if (child instanceof IField) {
if (stub && !Flags.isEnum(flags) && !Flags.isSynthetic(flags))
appendFieldDeclaration((IField) child);
} else if (child instanceof IMethod) {
final IMethod method = (IMethod) child;
final String name = method.getElementName();
if (method.getDeclaringType().isEnum()) {
final int count = method.getNumberOfParameters();
if (count == 0 && "values".equals(name)) // $NON-NLS-1$
continue;
if (count == 1
&& "valueOf".equals(name)
&& "Ljava.lang.String;"
.equals(method.getParameterTypes()[0])) // $NON-NLS-1$ //$NON-NLS-2$
continue;
if (method.isConstructor()) continue;
}
boolean skip = !stub || name.equals("<clinit>"); // $NON-NLS-1$
if (method.isConstructor()) skip = false;
skip = skip || Flags.isSynthetic(flags) || Flags.isBridge(flags);
if (!skip) appendMethodDeclaration(method);
}
fBuffer.append("\n"); // $NON-NLS-1$
}
} finally {
monitor.done();
}
}
示例8: computeJavaAdornmentFlags
import org.eclipse.jdt.core.IMember; //导入方法依赖的package包/类
private int computeJavaAdornmentFlags(IJavaElement element, int renderFlags) {
int flags = 0;
if (showOverlayIcons(renderFlags)) {
try {
if (element instanceof IMember) {
IMember member = (IMember) element;
int modifiers = member.getFlags();
if (confirmAbstract(member) && JdtFlags.isAbstract(member))
flags |= JavaElementImageDescriptor.ABSTRACT;
if (Flags.isFinal(modifiers)
|| isInterfaceOrAnnotationField(member)
|| isEnumConstant(member, modifiers)) flags |= JavaElementImageDescriptor.FINAL;
if (Flags.isStatic(modifiers)
|| isInterfaceOrAnnotationFieldOrType(member)
|| isEnumConstant(member, modifiers)) flags |= JavaElementImageDescriptor.STATIC;
if (Flags.isDeprecated(modifiers)) flags |= JavaElementImageDescriptor.DEPRECATED;
int elementType = element.getElementType();
if (elementType == IJavaElement.METHOD) {
if (((IMethod) element).isConstructor())
flags |= JavaElementImageDescriptor.CONSTRUCTOR;
if (Flags.isSynchronized(modifiers)) // collides with 'super' flag
flags |= JavaElementImageDescriptor.SYNCHRONIZED;
if (Flags.isNative(modifiers)) flags |= JavaElementImageDescriptor.NATIVE;
if (Flags.isDefaultMethod(modifiers))
flags |= JavaElementImageDescriptor.DEFAULT_METHOD;
if (Flags.isAnnnotationDefault(modifiers))
flags |= JavaElementImageDescriptor.ANNOTATION_DEFAULT;
}
if (member.getElementType() == IJavaElement.TYPE) {
if (JavaModelUtil.hasMainMethod((IType) member)) {
flags |= JavaElementImageDescriptor.RUNNABLE;
}
}
if (member.getElementType() == IJavaElement.FIELD) {
if (Flags.isVolatile(modifiers)) flags |= JavaElementImageDescriptor.VOLATILE;
if (Flags.isTransient(modifiers)) flags |= JavaElementImageDescriptor.TRANSIENT;
}
} else if (element instanceof ILocalVariable
&& Flags.isFinal(((ILocalVariable) element).getFlags())) {
flags |= JavaElementImageDescriptor.FINAL;
}
} catch (JavaModelException e) {
// do nothing. Can't compute runnable adornment or get flags
}
}
return flags;
}