本文整理汇总了Java中org.eclipse.jdt.core.dom.IBinding.getModifiers方法的典型用法代码示例。如果您正苦于以下问题:Java IBinding.getModifiers方法的具体用法?Java IBinding.getModifiers怎么用?Java IBinding.getModifiers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.dom.IBinding
的用法示例。
在下文中一共展示了IBinding.getModifiers方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isVisible
import org.eclipse.jdt.core.dom.IBinding; //导入方法依赖的package包/类
/**
* Evaluates if the declaration is visible in a certain context.
*
* @param binding The binding of the declaration to examine
* @param context The context to test in
* @return Returns
*/
public static boolean isVisible(IBinding binding, ITypeBinding context) {
if (binding.getKind() == IBinding.VARIABLE && !((IVariableBinding) binding).isField()) {
return true; // all local variables found are visible
}
ITypeBinding declaring = getDeclaringType(binding);
if (declaring == null) {
return false;
}
declaring = declaring.getTypeDeclaration();
int modifiers = binding.getModifiers();
if (Modifier.isPublic(modifiers) || declaring.isInterface()) {
return true;
} else if (Modifier.isProtected(modifiers) || !Modifier.isPrivate(modifiers)) {
if (declaring.getPackage() == context.getPackage()) {
return true;
}
return isTypeInScope(declaring, context, Modifier.isProtected(modifiers));
}
// private visibility
return isTypeInScope(declaring, context, false);
}
示例2: findConstantNameNode
import org.eclipse.jdt.core.dom.IBinding; //导入方法依赖的package包/类
private Name findConstantNameNode() {
ASTNode node =
NodeFinder.perform(fSelectionCuRewrite.getRoot(), fSelectionStart, fSelectionLength);
if (node == null) return null;
if (node instanceof FieldAccess) node = ((FieldAccess) node).getName();
if (!(node instanceof Name)) return null;
Name name = (Name) node;
IBinding binding = name.resolveBinding();
if (!(binding instanceof IVariableBinding)) return null;
IVariableBinding variableBinding = (IVariableBinding) binding;
if (!variableBinding.isField() || variableBinding.isEnumConstant()) return null;
int modifiers = binding.getModifiers();
if (!(Modifier.isStatic(modifiers) && Modifier.isFinal(modifiers))) return null;
return name;
}
示例3: getAdornmentFlags
import org.eclipse.jdt.core.dom.IBinding; //导入方法依赖的package包/类
private static int getAdornmentFlags(IBinding binding) {
int adornments = 0;
final int modifiers = binding.getModifiers();
if (Modifier.isAbstract(modifiers)) adornments |= JavaElementImageDescriptor.ABSTRACT;
if (Modifier.isFinal(modifiers)) adornments |= JavaElementImageDescriptor.FINAL;
if (Modifier.isStatic(modifiers)) adornments |= JavaElementImageDescriptor.STATIC;
if (binding.isDeprecated()) adornments |= JavaElementImageDescriptor.DEPRECATED;
if (binding instanceof IMethodBinding) {
if (((IMethodBinding) binding).isConstructor())
adornments |= JavaElementImageDescriptor.CONSTRUCTOR;
if (Modifier.isSynchronized(modifiers)) adornments |= JavaElementImageDescriptor.SYNCHRONIZED;
if (Modifier.isNative(modifiers)) adornments |= JavaElementImageDescriptor.NATIVE;
ITypeBinding type = ((IMethodBinding) binding).getDeclaringClass();
if (type.isInterface() && !Modifier.isAbstract(modifiers) && !Modifier.isStatic(modifiers))
adornments |= JavaElementImageDescriptor.DEFAULT_METHOD;
if (((IMethodBinding) binding).getDefaultValue() != null)
adornments |= JavaElementImageDescriptor.ANNOTATION_DEFAULT;
}
if (binding instanceof IVariableBinding && ((IVariableBinding) binding).isField()) {
if (Modifier.isTransient(modifiers)) adornments |= JavaElementImageDescriptor.TRANSIENT;
if (Modifier.isVolatile(modifiers)) adornments |= JavaElementImageDescriptor.VOLATILE;
}
return adornments;
}
示例4: getBaseImageDescriptor
import org.eclipse.jdt.core.dom.IBinding; //导入方法依赖的package包/类
private static ImageDescriptor getBaseImageDescriptor(IBinding binding, int flags) {
if (binding instanceof ITypeBinding) {
ITypeBinding typeBinding = (ITypeBinding) binding;
if (typeBinding.isArray()) {
typeBinding = typeBinding.getElementType();
}
if (typeBinding.isCapture()) {
typeBinding.getWildcard();
}
return getTypeImageDescriptor(typeBinding.getDeclaringClass() != null, typeBinding, flags);
} else if (binding instanceof IMethodBinding) {
ITypeBinding type = ((IMethodBinding) binding).getDeclaringClass();
int modifiers = binding.getModifiers();
if (type.isEnum()
&& (!Modifier.isPublic(modifiers)
&& !Modifier.isProtected(modifiers)
&& !Modifier.isPrivate(modifiers))
&& ((IMethodBinding) binding).isConstructor()) return JavaPluginImages.DESC_MISC_PRIVATE;
return getMethodImageDescriptor(binding.getModifiers());
} else if (binding instanceof IVariableBinding)
return getFieldImageDescriptor((IVariableBinding) binding);
return JavaPluginImages.DESC_OBJS_UNKNOWN;
}
示例5: consumes
import org.eclipse.jdt.core.dom.IBinding; //导入方法依赖的package包/类
@Override
public boolean consumes(SemanticToken token) {
SimpleName node = token.getNode();
if (node.isDeclaration()) return false;
IBinding binding = token.getBinding();
boolean isAbstractMethod =
binding != null
&& binding.getKind() == IBinding.METHOD
&& (binding.getModifiers() & Modifier.ABSTRACT) == Modifier.ABSTRACT;
if (!isAbstractMethod) return false;
// filter out annotation value references
if (binding != null) {
ITypeBinding declaringType = ((IMethodBinding) binding).getDeclaringClass();
if (declaringType.isAnnotation()) return false;
}
return true;
}
示例6: getModifier
import org.eclipse.jdt.core.dom.IBinding; //导入方法依赖的package包/类
private static String getModifier(IBinding ib) {
if ((ib.getModifiers() & Modifier.PUBLIC) > 0)
return Fact.PUBLIC;
else if ((ib.getModifiers() & Modifier.PROTECTED) > 0)
return Fact.PROTECTED;
else if ((ib.getModifiers() & Modifier.PRIVATE) > 0)
return Fact.PRIVATE;
else
return Fact.PACKAGE;
}
示例7: getModifier
import org.eclipse.jdt.core.dom.IBinding; //导入方法依赖的package包/类
private static String getModifier(IBinding ib)
{
if ((ib.getModifiers() & 0x1) > 0) {
return "public";
}
if ((ib.getModifiers() & 0x4) > 0) {
return "protected";
}
if ((ib.getModifiers() & 0x2) > 0) {
return "private";
}
return "package";
}
示例8: isStaticAccess
import org.eclipse.jdt.core.dom.IBinding; //导入方法依赖的package包/类
private static boolean isStaticAccess(SimpleName memberName) {
IBinding binding = memberName.resolveBinding();
Assert.isTrue(
binding instanceof IVariableBinding
|| binding instanceof IMethodBinding
|| binding instanceof ITypeBinding);
if (binding instanceof ITypeBinding) return true;
if (binding instanceof IVariableBinding) return ((IVariableBinding) binding).isField();
int modifiers = binding.getModifiers();
return Modifier.isStatic(modifiers);
}
示例9: visitName
import org.eclipse.jdt.core.dom.IBinding; //导入方法依赖的package包/类
private boolean visitName(Name name) {
IBinding binding = name.resolveBinding();
if (binding == null) {
/* If the binding is null because of compile errors etc.,
scenarios which may have been deemed unacceptable in
the presence of semantic information will be admitted.
Descend deeper.
*/
return true;
}
int modifiers = binding.getModifiers();
if (binding instanceof IVariableBinding) {
if (!(Modifier.isStatic(modifiers) && Modifier.isFinal(modifiers))) {
fResult = false;
return false;
}
} else if (binding instanceof IMethodBinding) {
if (!Modifier.isStatic(modifiers)) {
fResult = false;
return false;
}
} else if (binding instanceof ITypeBinding) {
return false; // It's o.k. Don't descend deeper.
} else {
return false; // e.g. a NameQualifiedType's qualifier, which can be a package binding
}
// Descend deeper:
return true;
}
示例10: BodyDeclaration
import org.eclipse.jdt.core.dom.IBinding; //导入方法依赖的package包/类
public BodyDeclaration(IBinding binding) {
modifiers = binding.getModifiers();
}