本文整理汇总了Java中org.eclipse.jdt.core.dom.Modifier.isPublic方法的典型用法代码示例。如果您正苦于以下问题:Java Modifier.isPublic方法的具体用法?Java Modifier.isPublic怎么用?Java Modifier.isPublic使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.dom.Modifier
的用法示例。
在下文中一共展示了Modifier.isPublic方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: getDelegateCandidates
import org.eclipse.jdt.core.dom.Modifier; //导入方法依赖的package包/类
private static IMethodBinding[] getDelegateCandidates(
ITypeBinding binding, ITypeBinding hierarchy) {
List<IMethodBinding> allMethods = new ArrayList<IMethodBinding>();
boolean isInterface = binding.isInterface();
IMethodBinding[] typeMethods = binding.getDeclaredMethods();
for (int index = 0; index < typeMethods.length; index++) {
final int modifiers = typeMethods[index].getModifiers();
if (!typeMethods[index].isConstructor()
&& !Modifier.isStatic(modifiers)
&& (isInterface || Modifier.isPublic(modifiers))) {
IMethodBinding result =
Bindings.findOverriddenMethodInHierarchy(hierarchy, typeMethods[index]);
if (result != null && Flags.isFinal(result.getModifiers())) continue;
ITypeBinding[] parameterBindings = typeMethods[index].getParameterTypes();
boolean upper = false;
for (int offset = 0; offset < parameterBindings.length; offset++) {
if (parameterBindings[offset].isWildcardType()
&& parameterBindings[offset].isUpperbound()) upper = true;
}
if (!upper) allMethods.add(typeMethods[index]);
}
}
return allMethods.toArray(new IMethodBinding[allMethods.size()]);
}
示例3: 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));
}
}
}
示例4: adjustOutgoingVisibilityChain
import org.eclipse.jdt.core.dom.Modifier; //导入方法依赖的package包/类
private void adjustOutgoingVisibilityChain(final IMember member, final IProgressMonitor monitor)
throws JavaModelException {
if (!Modifier.isPublic(member.getFlags())) {
final ModifierKeyword threshold =
computeOutgoingVisibilityThreshold(fReferencing, member, monitor);
if (member instanceof IMethod) {
adjustOutgoingVisibility(
member,
threshold,
RefactoringCoreMessages.MemberVisibilityAdjustor_change_visibility_method_warning);
} else if (member instanceof IField) {
adjustOutgoingVisibility((IField) member, threshold);
} else if (member instanceof IType) {
adjustOutgoingVisibility(
member,
threshold,
RefactoringCoreMessages.MemberVisibilityAdjustor_change_visibility_type_warning);
}
}
if (member.getDeclaringType() != null)
adjustOutgoingVisibilityChain(member.getDeclaringType(), monitor);
}
示例5: 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;
}
示例6: 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";
}
示例7: 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();
}
示例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: visit
import org.eclipse.jdt.core.dom.Modifier; //导入方法依赖的package包/类
@Override
public boolean visit(MethodDeclaration methodDecl) {
int modifiers = methodDecl.getModifiers();
if(Modifier.isPublic(modifiers) && !methodDecl.isConstructor() && !methodDecl.getReturnType2().isPrimitiveType()){
Block body = methodDecl.getBody();
if(body!=null){
List<Statement> statements = body.statements();
for (Statement stmnt : statements) {
if(stmnt instanceof ReturnStatement){
ReturnStatement retStmnt = (ReturnStatement)stmnt;
Expression expression = retStmnt.getExpression();
if(expression instanceof SimpleName){
SimpleName simpleExpr = (SimpleName)expression;
IBinding resolveBinding = simpleExpr.resolveBinding();
Variable variable = context.getAllBindingKeyToVariableMap(resolveBinding.getKey());
if(variable!=null){
context.removeEncapsulatedVariable(variable);
}
}
}
}
}
}
return super.visit(methodDecl);
}
示例10: tCall_PassingOwnedToPublicMethod
import org.eclipse.jdt.core.dom.Modifier; //导入方法依赖的package包/类
/**
* T-Invk: cannot pass an argument with 'owned' in signature to a public method
*
* XXX. Pass receiver too to double-check
*
* @param methodName
* @param methodEnclosingClass
* @param argumentTypingSet
* @return
*/
public static void tCall_PassingOwnedToPublicMethod(IMethodBinding methodBinding, Set<OType> argumentTypingSet){
Iterator<OType> it = argumentTypingSet.iterator();
if(Modifier.isPublic(methodBinding.getModifiers())){
while (it.hasNext()) {
OType oType = it.next();
if(oType.getOwner().contains("owned") || oType.getAlpha().contains("owned")){
it.remove();
}
}
}
}
示例11: printModifiers
import org.eclipse.jdt.core.dom.Modifier; //导入方法依赖的package包/类
private void printModifiers(int modifiers) {
if (Modifier.isPublic(modifiers)) {
sb.print("public ");
}
if (Modifier.isProtected(modifiers)) {
sb.print("protected ");
}
if (Modifier.isPrivate(modifiers)) {
sb.print("private ");
}
if (Modifier.isStatic(modifiers)) {
sb.print("static ");
}
if (Modifier.isAbstract(modifiers)) {
sb.print("abstract ");
}
if (Modifier.isFinal(modifiers)) {
sb.print("final ");
}
if (Modifier.isSynchronized(modifiers)) {
sb.print("synchronized ");
}
if (Modifier.isVolatile(modifiers)) {
sb.print("volatile ");
}
if (Modifier.isNative(modifiers)) {
sb.print("native ");
}
if (Modifier.isStrictfp(modifiers)) {
sb.print("strictfp ");
}
if (Modifier.isTransient(modifiers)) {
sb.print("transient ");
}
if ((modifiers & BindingUtil.ACC_SYNTHETIC) > 0) {
sb.print("synthetic ");
}
}
示例12: 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();
}
示例13: 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;
}
示例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: 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;
}