本文整理匯總了Java中org.eclipse.jdt.core.dom.ITypeBinding.getModifiers方法的典型用法代碼示例。如果您正苦於以下問題:Java ITypeBinding.getModifiers方法的具體用法?Java ITypeBinding.getModifiers怎麽用?Java ITypeBinding.getModifiers使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jdt.core.dom.ITypeBinding
的用法示例。
在下文中一共展示了ITypeBinding.getModifiers方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: needsImport
import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
private boolean needsImport(ITypeBinding typeBinding, SimpleName ref) {
if (!typeBinding.isTopLevel() && !typeBinding.isMember() || typeBinding.isRecovered()) {
return false; // no imports for anonymous, local, primitive types or parameters types
}
int modifiers= typeBinding.getModifiers();
if (Modifier.isPrivate(modifiers)) {
return false; // imports for privates are not required
}
ITypeBinding currTypeBinding= Bindings.getBindingOfParentType(ref);
if (currTypeBinding == null) {
if (ASTNodes.getParent(ref, ASTNode.PACKAGE_DECLARATION) != null) {
return true; // reference in package-info.java
}
return false; // not in a type
}
if (!Modifier.isPublic(modifiers)) {
if (!currTypeBinding.getPackage().getName().equals(typeBinding.getPackage().getName())) {
return false; // not visible
}
}
ASTNode parent= ref.getParent();
while (parent instanceof Type) {
parent= parent.getParent();
}
if (parent instanceof AbstractTypeDeclaration && parent.getParent() instanceof CompilationUnit) {
return true;
}
if (typeBinding.isMember()) {
if (fAnalyzer.isDeclaredInScope(typeBinding, ref, ScopeAnalyzer.TYPES | ScopeAnalyzer.CHECK_VISIBILITY)) {
return false;
}
}
return true;
}
示例2: getInfoIcon
import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
public static Image getInfoIcon(Object element) {
if(element instanceof Info<?>){
switch(((Info) element).getType()){
case CLASS:
ITypeBinding typeBinding = Crystal.getInstance().getTypeBindingFromName((((Info) element).getKey()));
if(typeBinding!=null){
List<ImageDescriptor> overlayIcons = new ArrayList<ImageDescriptor>();
int typeModifiers = typeBinding.getModifiers();
if(Modifier.isAbstract(typeModifiers)){
overlayIcons.add(getImageDescriptor(IMG_ABSTRACT_CO));
}else if(Modifier.isStatic(typeModifiers)){
overlayIcons.add(getImageDescriptor(IMG_STATIC_CO));
}else if(Modifier.isPrivate(typeModifiers)){
overlayIcons.add(getImageDescriptor(IMG_PRIVATE_CO));
}
Image baseImage = JavaPluginImages.get(ISharedImages.IMG_OBJS_CLASS);
DecorationOverlayIcon image = new DecorationOverlayIcon(baseImage, overlayIcons.toArray(new ImageDescriptor[0]));
return image.createImage();
}
break;
case METHOD:
MethodDeclaration methodDeclaration = ASTUtils.getMethodDeclaration(((Info) element).getKey());
if(methodDeclaration!=null){
String icon= IMG_PUBLIC_CO;
if(methodDeclaration!=null){
int modifiers = methodDeclaration.getModifiers();
if(Modifier.isPrivate(modifiers)){
icon = IMG_PRIVATE_CO;
}else if(Modifier.isProtected(modifiers)){
icon = IMG_PROTECTED_CO;
}else{
}
}
ImageDescriptor imageDescriptor = getImageDescriptor(icon);
return imageDescriptor.createImage();
}
break;
}
}
return null;
}