本文整理匯總了Java中org.eclipse.jdt.core.dom.Modifier.isProtected方法的典型用法代碼示例。如果您正苦於以下問題:Java Modifier.isProtected方法的具體用法?Java Modifier.isProtected怎麽用?Java Modifier.isProtected使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jdt.core.dom.Modifier
的用法示例。
在下文中一共展示了Modifier.isProtected方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: visit
import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
@Override
public boolean visit(FieldDeclaration node) {
int modifiers = node.getModifiers();
if (Modifier.isPrivate(modifiers) || Modifier.isProtected(modifiers)) {
List<VariableDeclarationFragment> fragments = node.fragments();
for (VariableDeclarationFragment varDeclFrag : fragments) {
IVariableBinding varBinding = varDeclFrag.resolveBinding();
String enclosingClass = varBinding.getDeclaringClass().getQualifiedName();
if(!varBinding.getType().isPrimitive() && !varBinding.getType().getQualifiedName().equals("java.lang.String")){
final TACVariable fieldVar = new TACVariable(varBinding);
if(!enclosingClass.equals(Config.MAINCLASS)){
context.addEncapsulatedVariable(fieldVar);
}
}
}
}
return super.visit(node);
}
示例2: isVisible
import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的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);
}
示例3: getBaseImageDescriptor
import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的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;
}
示例4: checkModifiers
import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
public static void checkModifiers(ProblemCollector collector, BodyDeclaration elem,
Predicate<Modifier> allowSpecific) {
for (Object obj : elem.modifiers()) {
if (!(obj instanceof Modifier)) {
continue;
}
Modifier modifier = (Modifier) obj;
boolean valid;
if (allowSpecific.test(modifier)) {
valid = true;
} else {
valid = modifier.isPrivate() || modifier.isPublic() || modifier.isProtected() || modifier.isFinal();
}
if (!valid) {
collector.report(new InvalidModifier(collector.getSourceInfo(), modifier));
}
}
}
示例5: getVisibility
import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
private static String getVisibility(TypeDeclaration decl) {
int modifiers = decl.getModifiers();
if (Modifier.isPrivate(modifiers))
return "private";
if (Modifier.isProtected(modifiers))
return "protected";
if (Modifier.isPublic(modifiers))
return "public";
return "package";
}
示例6: isVisibleInHierarchy
import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
public static boolean isVisibleInHierarchy(IMethodBinding member, IPackageBinding pack) {
int otherflags= member.getModifiers();
ITypeBinding declaringType= member.getDeclaringClass();
if (Modifier.isPublic(otherflags) || Modifier.isProtected(otherflags) || (declaringType != null && declaringType.isInterface())) {
return true;
} else if (Modifier.isPrivate(otherflags)) {
return false;
}
return declaringType != null && pack == declaringType.getPackage();
}
示例7: extractBasicModifiersFromBinding
import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
private void extractBasicModifiersFromBinding(int modifiers, NamedEntity entity) {
Boolean publicModifier = Modifier.isPublic(modifiers);
Boolean protectedModifier = Modifier.isProtected(modifiers);
Boolean privateModifier = Modifier.isPrivate(modifiers);
if (publicModifier )
entity.addModifiers("public");
if (protectedModifier)
entity.addModifiers("protected");
if (privateModifier)
entity.addModifiers("private");
if (!(publicModifier || protectedModifier || privateModifier))
entity.addModifiers("package");
if (Modifier.isFinal(modifiers))
entity.addModifiers("final");
if (Modifier.isAbstract(modifiers))
entity.addModifiers("abstract");
if (Modifier.isNative(modifiers))
entity.addModifiers("native");
if (Modifier.isSynchronized(modifiers))
entity.addModifiers("synchronized");
if (Modifier.isTransient(modifiers))
entity.addModifiers("transient");
if (Modifier.isVolatile(modifiers))
entity.addModifiers("volatile");
/* We do not extract the static modifier here because we want to set the hasClassScope property
and we do that specifically only for attributes and methods */
}
示例8: isVisibleInHierarchy
import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
public static boolean isVisibleInHierarchy(IMethodBinding member, IPackageBinding pack) {
int otherflags = member.getModifiers();
ITypeBinding declaringType = member.getDeclaringClass();
if (Modifier.isPublic(otherflags)
|| Modifier.isProtected(otherflags)
|| (declaringType != null && declaringType.isInterface())) {
return true;
} else if (Modifier.isPrivate(otherflags)) {
return false;
}
return declaringType != null && pack == declaringType.getPackage();
}
示例9: getAccessModifier
import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
private static int getAccessModifier(AbstractTypeDeclaration subclass) {
int modifiers = subclass.getModifiers();
if (Modifier.isPublic(modifiers)) return Modifier.PUBLIC;
else if (Modifier.isProtected(modifiers)) return Modifier.PROTECTED;
else if (Modifier.isPrivate(modifiers)) return Modifier.PRIVATE;
else return Modifier.NONE;
}
示例10: getVisibilityString
import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
private static String getVisibilityString(int code) {
if (Modifier.isPublic(code)) {
return "public"; // $NON-NLS-1$
} else if (Modifier.isProtected(code)) {
return "protected"; // $NON-NLS-1$
} else if (Modifier.isPrivate(code)) {
return "private"; // $NON-NLS-1$
}
return CorrectionMessages.ModifierCorrectionSubProcessor_default;
}
示例11: getFieldImageDescriptor
import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
private static ImageDescriptor getFieldImageDescriptor(IVariableBinding binding) {
final int modifiers = binding.getModifiers();
if (Modifier.isPublic(modifiers) || binding.isEnumConstant())
return JavaPluginImages.DESC_FIELD_PUBLIC;
if (Modifier.isProtected(modifiers)) return JavaPluginImages.DESC_FIELD_PROTECTED;
if (Modifier.isPrivate(modifiers)) return JavaPluginImages.DESC_FIELD_PRIVATE;
return JavaPluginImages.DESC_FIELD_DEFAULT;
}
示例12: getInnerClassImageDescriptor
import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
private static ImageDescriptor getInnerClassImageDescriptor(int modifiers) {
if (Modifier.isPublic(modifiers)) return JavaPluginImages.DESC_OBJS_INNER_CLASS_PUBLIC;
else if (Modifier.isPrivate(modifiers)) return JavaPluginImages.DESC_OBJS_INNER_CLASS_PRIVATE;
else if (Modifier.isProtected(modifiers))
return JavaPluginImages.DESC_OBJS_INNER_CLASS_PROTECTED;
else return JavaPluginImages.DESC_OBJS_INNER_CLASS_DEFAULT;
}
示例13: getInnerInterfaceImageDescriptor
import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
private static ImageDescriptor getInnerInterfaceImageDescriptor(int modifiers) {
if (Modifier.isPublic(modifiers)) return JavaPluginImages.DESC_OBJS_INNER_INTERFACE_PUBLIC;
else if (Modifier.isPrivate(modifiers))
return JavaPluginImages.DESC_OBJS_INNER_INTERFACE_PRIVATE;
else if (Modifier.isProtected(modifiers))
return JavaPluginImages.DESC_OBJS_INNER_INTERFACE_PROTECTED;
else return JavaPluginImages.DESC_OBJS_INTERFACE_DEFAULT;
}
示例14: getMethodImageDescriptor
import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
private static ImageDescriptor getMethodImageDescriptor(int modifiers) {
if (Modifier.isPublic(modifiers)) return JavaPluginImages.DESC_MISC_PUBLIC;
if (Modifier.isProtected(modifiers)) return JavaPluginImages.DESC_MISC_PROTECTED;
if (Modifier.isPrivate(modifiers)) return JavaPluginImages.DESC_MISC_PRIVATE;
return JavaPluginImages.DESC_MISC_DEFAULT;
}
示例15: getInfoIcon
import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的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;
}