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


Java IBinding.getModifiers方法代码示例

本文整理汇总了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);
}
 
开发者ID:eclipse,项目名称:che,代码行数:31,代码来源:ScopeAnalyzer.java

示例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;
}
 
开发者ID:eclipse,项目名称:che,代码行数:17,代码来源:InlineConstantRefactoring.java

示例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;
}
 
开发者ID:eclipse,项目名称:che,代码行数:27,代码来源:BindingLabelProvider.java

示例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;
}
 
开发者ID:eclipse,项目名称:che,代码行数:24,代码来源:BindingLabelProvider.java

示例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;
}
 
开发者ID:eclipse,项目名称:che,代码行数:21,代码来源:SemanticHighlightings.java

示例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;
}
 
开发者ID:aserg-ufmg,项目名称:RefDiff,代码行数:11,代码来源:ASTVisitorAtomicChange.java

示例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";
}
 
开发者ID:SEAL-UCLA,项目名称:Ref-Finder,代码行数:14,代码来源:ASTVisitorAtomicChange.java

示例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);
}
 
开发者ID:eclipse,项目名称:che,代码行数:15,代码来源:InlineConstantRefactoring.java

示例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;
}
 
开发者ID:eclipse,项目名称:che,代码行数:33,代码来源:ConstantChecks.java

示例10: BodyDeclaration

import org.eclipse.jdt.core.dom.IBinding; //导入方法依赖的package包/类
public BodyDeclaration(IBinding binding) {
  modifiers = binding.getModifiers();
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:4,代码来源:BodyDeclaration.java


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