for (final FieldBinding fieldBinding : referenceBinding.fields()) { if (name.equals(new String(fieldBinding.readableName()))) { final String qualifiedNameOfParent = new String(referenceBinding.readableName()); final CtType parentOfField = referenceBinding.isClass() ? classFactory.create(qualifiedNameOfParent) : interfaceFactory.create(qualifiedNameOfParent); final ReferenceBinding superclass = referenceBinding.superclass(); if (superclass != null) { referenceBindings.push(superclass); final ReferenceBinding[] interfaces = referenceBinding.superInterfaces(); if (interfaces != null) { for (ReferenceBinding rb : interfaces) {
static int numberOfEnclosingFields(ReferenceBinding type){ int count = 0; type = type.enclosingType(); while(type != null) { count += type.fieldCount(); type = type.enclosingType(); } return count; }
/** * Searches a type from an entry-point according to a simple name. * * @param type * Entry-point to search. * @param simpleName * Expected type name. * @return type binding. */ static TypeBinding searchTypeBinding(ReferenceBinding type, String simpleName) { if (simpleName == null || type == null) { return null; } if (type.memberTypes() != null) { for (ReferenceBinding memberType : type.memberTypes()) { if (simpleName.equals(CharOperation.charToString(memberType.sourceName()))) { return memberType; } } } return searchTypeBinding(type.superclass(), simpleName); }
@Override public NestingKind getNestingKind() { ReferenceBinding refBinding = (ReferenceBinding)_binding; if (refBinding.isAnonymousType()) { return NestingKind.ANONYMOUS; } else if (refBinding.isLocalType()) { return NestingKind.LOCAL; } else if (refBinding.isMemberType()) { return NestingKind.MEMBER; } return NestingKind.TOP_LEVEL; }
private void getAllInheritedMethods0(ReferenceBinding binding, ArrayList<MethodBinding> collector) { if (!binding.isInterface()) return; MethodBinding[] methodBindings = binding.methods(); for (int i = 0, max = methodBindings.length; i < max; i++) { collector.add(methodBindings[i]); } ReferenceBinding[] superInterfaces = binding.superInterfaces(); for (int i = 0, max = superInterfaces.length; i < max; i++) { getAllInheritedMethods0(superInterfaces[i], collector); } }
@Override protected AnnotationBinding[] getAnnotationBindings() { PackageBinding packageBinding = (PackageBinding) this._binding; char[][] compoundName = CharOperation.arrayConcat(packageBinding.compoundName, TypeConstants.PACKAGE_INFO_NAME); ReferenceBinding type = this._env.getLookupEnvironment().getType(compoundName); AnnotationBinding[] annotations = null; if (type != null && type.isValidBinding()) { annotations = type.getAnnotations(); } return annotations; }
public ReferenceBinding getMemberType(char[] typeName) { ReferenceBinding[] memberTypes = memberTypes(); for (int i = memberTypes.length; --i >= 0;) if (CharOperation.equals(memberTypes[i].sourceName, typeName)) return memberTypes[i]; return null; }
/** * Return the array of resolvable fields (resilience) */ public FieldBinding[] availableFields() { return fields(); }
public MethodBinding[] getMethods(char[] selector) { if (this.upperBounds.length == 1 && this.upperBounds[0] instanceof ReferenceBinding) return ((ReferenceBinding)this.upperBounds[0]).getMethods(selector); return super.getMethods(selector); }
@Override public TypeMirror getSuperclass() { ReferenceBinding binding = (ReferenceBinding)_binding; ReferenceBinding superBinding = binding.superclass(); if (null == superBinding || binding.isInterface()) { return _env.getFactory().getNoType(TypeKind.NONE); } // superclass of a type must be a DeclaredType return _env.getFactory().newTypeMirror(superBinding); }
/** * Checks if the qualified name reference is a problem field binding and have a valid field. * * @param qualifiedNameReference * Reference which should contains a problem field binding. * @return true if the qualified name reference is a valid problem field binding. */ static boolean isValidProblemBindingField(QualifiedNameReference qualifiedNameReference) { return qualifiedNameReference.binding instanceof ProblemFieldBinding && !((FieldBinding) qualifiedNameReference.binding).declaringClass.isAnonymousType() && qualifiedNameReference.tokens.length - 1 == ((FieldBinding) qualifiedNameReference.binding).declaringClass.compoundName.length && CharOperation .equals(CharOperation.subarray(qualifiedNameReference.tokens, 0, qualifiedNameReference.tokens.length - 1), ((FieldBinding) qualifiedNameReference.binding).declaringClass.compoundName); }
public ReferenceBinding[] syntheticEnclosingInstanceTypes() { if (isStatic()) return null; ReferenceBinding enclosingType = enclosingType(); if (enclosingType == null) return null; return new ReferenceBinding[] {enclosingType}; }
boolean isSameClassOrSubclassOf(ReferenceBinding testClass, ReferenceBinding superclass) { do { if (TypeBinding.equalsEquals(testClass, superclass)) return true; } while ((testClass = testClass.superclass()) != null); return false; }
@Override protected AnnotationBinding[] getAnnotationBindings() { return ((ReferenceBinding)_binding).getAnnotations(); }
public final ReferenceBinding outermostEnclosingType() { ReferenceBinding current = this; while (true) { ReferenceBinding last = current; if ((current = current.enclosingType()) == null) return last; } }
private static MethodBinding findInSuperclassHierarchy(MethodBinding baseMethod, ReferenceBinding typeBinding) { while ( typeBinding != null ) { MethodBinding matching = findMatchingMethodBinding( baseMethod, typeBinding.methods() ); if ( matching != null ) { return matching; } typeBinding = typeBinding.superclass(); } return null; }
@NonNull @Override public PsiClass[] getSupers() { return mManager.findClasses(mTypeBinding.superclass(), mTypeBinding.superInterfaces()); }
public boolean isProperType(boolean admitCapture18) { ReferenceBinding outer = enclosingType(); if (outer != null && !outer.isProperType(admitCapture18)) return false; return super.isProperType(admitCapture18); }
/** * Return the array of resolvable methods (resilience) */ public MethodBinding[] availableMethods() { return methods(); }
@Override public boolean isEnum() { return mTypeBinding.isEnum(); }