本文整理匯總了Java中org.eclipse.jdt.core.dom.Modifier.isPrivate方法的典型用法代碼示例。如果您正苦於以下問題:Java Modifier.isPrivate方法的具體用法?Java Modifier.isPrivate怎麽用?Java Modifier.isPrivate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jdt.core.dom.Modifier
的用法示例。
在下文中一共展示了Modifier.isPrivate方法的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: 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));
}
}
}
示例3: getOverridableMethods
import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
private static void getOverridableMethods(
AST ast, ITypeBinding superBinding, List<IMethodBinding> allMethods) {
IMethodBinding[] methods = superBinding.getDeclaredMethods();
for (int offset = 0; offset < methods.length; offset++) {
final int modifiers = methods[offset].getModifiers();
if (!methods[offset].isConstructor()
&& !Modifier.isStatic(modifiers)
&& !Modifier.isPrivate(modifiers)) {
if (findOverridingMethod(methods[offset], allMethods) == null
&& !Modifier.isStatic(modifiers)) allMethods.add(methods[offset]);
}
}
ITypeBinding[] superInterfaces = superBinding.getInterfaces();
for (int index = 0; index < superInterfaces.length; index++) {
getOverridableMethods(ast, superInterfaces[index], allMethods);
}
}
示例4: 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;
}
示例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: getOverridableMethods
import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
private static void getOverridableMethods(AST ast, ITypeBinding superBinding, List<IMethodBinding> allMethods) {
IMethodBinding[] methods= superBinding.getDeclaredMethods();
for (int offset= 0; offset < methods.length; offset++) {
final int modifiers= methods[offset].getModifiers();
if (!methods[offset].isConstructor() && !Modifier.isStatic(modifiers) && !Modifier.isPrivate(modifiers)) {
if (findOverridingMethod(methods[offset], allMethods) == null) {
allMethods.add(methods[offset]);
}
}
}
ITypeBinding[] superInterfaces= superBinding.getInterfaces();
for (int index= 0; index < superInterfaces.length; index++) {
getOverridableMethods(ast, superInterfaces[index], allMethods);
}
}
示例8: needsImport
import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的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;
}
示例9: 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;
}
示例10: isInlinableConstant
import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
private boolean isInlinableConstant(BodyDeclaration decl) {
if (!(decl instanceof FieldDeclaration)) {
return false;
}
int modifiers = decl.getModifiers();
if (!Modifier.isStatic(modifiers) || !Modifier.isFinal(modifiers)
|| Modifier.isPrivate(modifiers)) {
return false;
}
ITypeBinding type = ((FieldDeclaration) decl).getType().getTypeBinding();
return type.isPrimitive() || Types.isStringType(type);
}
示例11: 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;
}
示例12: needsImport
import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的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;
}
示例13: 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;
}
示例14: 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;
}
示例15: 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;
}