List of usage examples for org.eclipse.jdt.core.dom Modifier isPrivate
public static boolean isPrivate(int flags)
From source file:at.bestsolution.fxide.jdt.corext.util.JdtFlags.java
License:Open Source License
public static boolean isPrivate(BodyDeclaration bodyDeclaration) { return Modifier.isPrivate(bodyDeclaration.getModifiers()); }
From source file:at.bestsolution.fxide.jdt.corext.util.JdtFlags.java
License:Open Source License
public static boolean isPrivate(IBinding binding) { return Modifier.isPrivate(binding.getModifiers()); }
From source file:at.bestsolution.fxide.jdt.corext.util.JdtFlags.java
License:Open Source License
public static String getVisibilityString(int visibilityCode) { if (Modifier.isPublic(visibilityCode)) return VISIBILITY_STRING_PUBLIC; if (Modifier.isProtected(visibilityCode)) return VISIBILITY_STRING_PROTECTED; if (Modifier.isPrivate(visibilityCode)) return VISIBILITY_STRING_PRIVATE; return VISIBILITY_STRING_PACKAGE; }
From source file:ca.ecliptical.pde.internal.ds.AnnotationProcessor.java
License:Open Source License
private IMethodBinding findReferenceMethod(ITypeBinding componentClass, ITypeBinding serviceType, String name) { ITypeBinding testedClass = componentClass; IMethodBinding candidate = null;//from w w w . j ava 2 s. c om int priority = 0; // priority: // 0: <assignment-compatible-type>, Map // 1: <exact-type>, Map // 2: <assignment-compatible-type> // 3: <exact-type> do { for (IMethodBinding declaredMethod : testedClass.getDeclaredMethods()) { if (name.equals(declaredMethod.getName()) && Void.TYPE.getName().equals(declaredMethod.getReturnType().getName()) && (testedClass.isEqualTo(componentClass) || Modifier.isPublic(declaredMethod.getModifiers()) || Modifier.isProtected(declaredMethod.getModifiers()) || (!Modifier.isPrivate(declaredMethod.getModifiers()) && testedClass.getPackage().isEqualTo(componentClass.getPackage())))) { ITypeBinding[] paramTypes = declaredMethod.getParameterTypes(); if (paramTypes.length == 1) { if (ServiceReference.class.getName().equals(paramTypes[0].getErasure().getQualifiedName())) // we have the winner return declaredMethod; if (priority < 3 && serviceType.isEqualTo(paramTypes[0])) priority = 3; else if (priority < 2 && serviceType.isAssignmentCompatible(paramTypes[0])) priority = 2; else continue; // we have a (better) candidate candidate = declaredMethod; } else if (paramTypes.length == 2) { if (priority < 1 && serviceType.isEqualTo(paramTypes[0]) && Map.class.getName().equals(paramTypes[1].getErasure().getQualifiedName())) priority = 1; else if (candidate != null || !serviceType.isAssignmentCompatible(paramTypes[0]) || !Map.class.getName().equals(paramTypes[1].getErasure().getQualifiedName())) continue; // we have a candidate candidate = declaredMethod; } } } } while ((testedClass = testedClass.getSuperclass()) != null); return candidate; }
From source file:coloredide.utils.CopiedNaiveASTFlattener.java
License:Open Source License
/** * Appends the text representation of the given modifier flags, followed by * a single space. Used for JLS2 modifiers. * //from w ww . j a v a2 s .co m * @param modifiers * the modifier flags */ void printModifiers(int modifiers) { if (Modifier.isPublic(modifiers)) { this.buffer.append("public ");//$NON-NLS-1$ } if (Modifier.isProtected(modifiers)) { this.buffer.append("protected ");//$NON-NLS-1$ } if (Modifier.isPrivate(modifiers)) { this.buffer.append("private ");//$NON-NLS-1$ } if (Modifier.isStatic(modifiers)) { this.buffer.append("static ");//$NON-NLS-1$ } if (Modifier.isAbstract(modifiers)) { this.buffer.append("abstract ");//$NON-NLS-1$ } if (Modifier.isFinal(modifiers)) { this.buffer.append("final ");//$NON-NLS-1$ } if (Modifier.isSynchronized(modifiers)) { this.buffer.append("synchronized ");//$NON-NLS-1$ } if (Modifier.isVolatile(modifiers)) { this.buffer.append("volatile ");//$NON-NLS-1$ } if (Modifier.isNative(modifiers)) { this.buffer.append("native ");//$NON-NLS-1$ } if (Modifier.isStrictfp(modifiers)) { this.buffer.append("strictfp ");//$NON-NLS-1$ } if (Modifier.isTransient(modifiers)) { this.buffer.append("transient ");//$NON-NLS-1$ } }
From source file:com.android.ide.eclipse.adt.internal.refactorings.extractstring.ReplaceStringsVisitor.java
License:Open Source License
/** * Find all method or fields that are candidates for providing a Context. * There can be various choices amongst this class or its super classes. * Sort them by rating in the results map. * * The best ever choice is to find a method with no argument that returns a Context. * The second suitable choice is to find a Context field. * The least desirable choice is to find a method with arguments. It's not really * desirable since we can't generate these arguments automatically. * * Methods and fields from supertypes are ignored if they are private. * * The rating is reversed: the lowest rating integer is used for the best candidate. * Because the superType argument is actually a recursion index, this makes the most * immediate classes more desirable.//from w w w .j ava 2 s . c o m * * @param results The map that accumulates the rating=>expression results. The lower * rating number is the best candidate. * @param clazzType The class examined. * @param superType The recursion index. * 0 for the immediate class, 1 for its super class, etc. */ private void findContextCandidates(TreeMap<Integer, Expression> results, ITypeBinding clazzType, int superType) { for (IMethodBinding mb : clazzType.getDeclaredMethods()) { // If we're looking at supertypes, we can't use private methods. if (superType != 0 && Modifier.isPrivate(mb.getModifiers())) { continue; } if (isAndroidContext(mb.getReturnType())) { // We found a method that returns something derived from Context. int argsLen = mb.getParameterTypes().length; if (argsLen == 0) { // We'll favor any method that takes no argument, // That would be the best candidate ever, so we can stop here. MethodInvocation mi = mAst.newMethodInvocation(); mi.setName(mAst.newSimpleName(mb.getName())); results.put(Integer.MIN_VALUE, mi); return; } else { // A method with arguments isn't as interesting since we wouldn't // know how to populate such arguments. We'll use it if there are // no other alternatives. We'll favor the one with the less arguments. Integer rating = Integer.valueOf(10000 + 1000 * superType + argsLen); if (!results.containsKey(rating)) { MethodInvocation mi = mAst.newMethodInvocation(); mi.setName(mAst.newSimpleName(mb.getName())); results.put(rating, mi); } } } } // A direct Context field would be more interesting than a method with // arguments. Try to find one. for (IVariableBinding var : clazzType.getDeclaredFields()) { // If we're looking at supertypes, we can't use private field. if (superType != 0 && Modifier.isPrivate(var.getModifiers())) { continue; } if (isAndroidContext(var.getType())) { // We found such a field. Let's use it. Integer rating = Integer.valueOf(superType); results.put(rating, mAst.newSimpleName(var.getName())); break; } } // Examine the super class to see if we can locate a better match clazzType = clazzType.getSuperclass(); if (clazzType != null) { findContextCandidates(results, clazzType, superType + 1); } }
From source file:com.architexa.diagrams.jdt.extractors.TypeMembersModifierExtractor.java
License:Open Source License
protected void addModifiers(Resource memberDeclRes, int modifiers) { if (Modifier.isPublic(modifiers)) rdfModel.addStatement(memberDeclRes, RJCore.access, RJCore.publicAccess); else if (Modifier.isProtected(modifiers)) rdfModel.addStatement(memberDeclRes, RJCore.access, RJCore.protectedAccess); else if (Modifier.isPrivate(modifiers)) rdfModel.addStatement(memberDeclRes, RJCore.access, RJCore.privateAccess); else/* w w w .j a v a 2 s .c om*/ rdfModel.addStatement(memberDeclRes, RJCore.access, RJCore.noAccess); // should also add static, final, abstract, etc. }
From source file:com.crispico.flower.mp.metamodel.codesyncjava.algorithm.JavaSyncUtils.java
License:Open Source License
/** * @flowerModelElementId _zVs8ZJiOEd6aNMdNFvR5WQ *//*from w w w . j a va 2 s . co m*/ public static ModifierKeyword getJavaVisibilityFlagFromJavaClass(BodyDeclaration bd) { if (Modifier.isPrivate(bd.getModifiers())) return ModifierKeyword.PRIVATE_KEYWORD; else if (Modifier.isProtected(bd.getModifiers())) return ModifierKeyword.PROTECTED_KEYWORD; else if (Modifier.isPublic(bd.getModifiers())) return ModifierKeyword.PUBLIC_KEYWORD; return null; }
From source file:com.drgarbage.ast.ASTGraphUtil.java
License:Apache License
private static void appendModifiers(int mod, StringBuffer buf) { if (Modifier.isAbstract(mod)) { buf.append(Modifier.ModifierKeyword.ABSTRACT_KEYWORD.toString()); buf.append(' '); }/*from w w w .j a va2 s . c o m*/ if (Modifier.isFinal(mod)) { buf.append(Modifier.ModifierKeyword.FINAL_KEYWORD.toString()); buf.append(' '); } if (Modifier.isNative(mod)) { buf.append(Modifier.ModifierKeyword.NATIVE_KEYWORD.toString()); buf.append(' '); } if (Modifier.isPrivate(mod)) { buf.append(Modifier.ModifierKeyword.PRIVATE_KEYWORD.toString()); buf.append(' '); } if (Modifier.isProtected(mod)) { buf.append(Modifier.ModifierKeyword.PROTECTED_KEYWORD.toString()); buf.append(' '); } if (Modifier.isPublic(mod)) { buf.append(Modifier.ModifierKeyword.PUBLIC_KEYWORD.toString()); buf.append(' '); } if (Modifier.isStatic(mod)) { buf.append(Modifier.ModifierKeyword.STATIC_KEYWORD.toString()); buf.append(' '); } if (Modifier.isStrictfp(mod)) { buf.append(Modifier.ModifierKeyword.STRICTFP_KEYWORD.toString()); buf.append(' '); } if (Modifier.isSynchronized(mod)) { buf.append(Modifier.ModifierKeyword.SYNCHRONIZED_KEYWORD.toString()); buf.append(' '); } if (Modifier.isTransient(mod)) { buf.append(Modifier.ModifierKeyword.TRANSIENT_KEYWORD.toString()); buf.append(' '); } if (Modifier.isVolatile(mod)) { buf.append(Modifier.ModifierKeyword.VOLATILE_KEYWORD.toString()); buf.append(' '); } }
From source file:com.github.parzonka.ccms.sorter.comparator.astextractor.AccessLevelComparatorExtractor.java
License:Open Source License
private static int getAccessLevel(MethodDeclaration method) { int modifiers = method.getModifiers(); if (Modifier.isPublic(modifiers)) return 0; if (Modifier.isProtected(modifiers)) return 1; if (Modifier.isPrivate(modifiers)) return 3; else/*from w w w . java 2 s . c o m*/ return 2; }