@Override public List<ResolvedReferenceType> getAncestors() { return ImmutableList. <ResolvedReferenceType>builder() .add(getSuperClass()) .addAll(superTypeDeclaration.asReferenceType().getAncestors()) .build(); }
@Override public List<ResolvedReferenceType> getAncestors(boolean acceptIncompleteList) { return ImmutableList. <ResolvedReferenceType>builder() .add(getSuperClass()) .addAll(superTypeDeclaration.asReferenceType().getAncestors(acceptIncompleteList)) .build(); }
@Override public List<ResolvedReferenceType> getAncestors() { return ImmutableList. <ResolvedReferenceType>builder() .add(getSuperClass()) .addAll(superTypeDeclaration.asReferenceType().getAncestors()) .build(); }
@Override public List<ResolvedReferenceType> getInterfaces() { return superTypeDeclaration .asReferenceType().getAncestors() .stream() .filter(type -> type.getTypeDeclaration().isInterface()) .collect(Collectors.toList()); }
@Override public List<ResolvedReferenceType> getInterfaces() { return superTypeDeclaration .asReferenceType().getAncestors() .stream() .filter(type -> type.getTypeDeclaration().isInterface()) .collect(Collectors.toList()); }
@Override public List<ResolvedReferenceType> getInterfaces() { return superTypeDeclaration .asReferenceType().getAncestors() .stream() .filter(type -> type.getTypeDeclaration().isInterface()) .collect(Collectors.toList()); }
/** * This method gets all direct and indirect Ancestors of a given class if * possible. (If ancestor is not a external dependency for example) * * @param currentClass * @return ancestors */ public static List<ResolvedReferenceType> getAllAncestors(ResolvedReferenceTypeDeclaration currentClass) { // Init ancestor list List<ResolvedReferenceType> ancestors = new ArrayList<>(); // Check class if (!(Object.class.getCanonicalName().equals(currentClass.getQualifiedName()))) { // Get all direct ancestors that can be resolved for (ResolvedReferenceType ancestor : currentClass.getAncestors(true)) { // Add them to list ancestors.add(ancestor); // Get indirect ancestors recursively for (ResolvedReferenceType inheritedAncestor : getAllAncestors(ancestor.getTypeDeclaration())) { if (!ancestors.contains(inheritedAncestor)) { ancestors.add(inheritedAncestor); } } } } return ancestors; }
static SymbolReference<ResolvedMethodDeclaration> solveMethod(String name, List<ResolvedType> parameterTypes, boolean staticOnly, TypeSolver typeSolver, ResolvedReferenceTypeDeclaration scopeType, Class clazz){ List<ResolvedMethodDeclaration> methods = new ArrayList<>(); Predicate<Method> staticOnlyCheck = m -> !staticOnly || (staticOnly && Modifier.isStatic(m.getModifiers())); for (Method method : clazz.getMethods()) { if (method.isBridge() || method.isSynthetic() || !method.getName().equals(name)|| !staticOnlyCheck.test(method)) continue; ResolvedMethodDeclaration methodDeclaration = new ReflectionMethodDeclaration(method, typeSolver); methods.add(methodDeclaration); } for (ResolvedReferenceType ancestor : scopeType.getAncestors()) { SymbolReference<ResolvedMethodDeclaration> ref = MethodResolutionLogic.solveMethodInType(ancestor.getTypeDeclaration(), name, parameterTypes, staticOnly, typeSolver); if (ref.isSolved()) { methods.add(ref.getCorrespondingDeclaration()); } } if (scopeType.getAncestors().isEmpty()){ ReferenceTypeImpl objectClass = new ReferenceTypeImpl(new ReflectionClassDeclaration(Object.class, typeSolver), typeSolver); SymbolReference<ResolvedMethodDeclaration> ref = MethodResolutionLogic.solveMethodInType(objectClass.getTypeDeclaration(), name, parameterTypes, staticOnly, typeSolver); if (ref.isSolved()) { methods.add(ref.getCorrespondingDeclaration()); } } return MethodResolutionLogic.findMostApplicable(methods, name, parameterTypes, typeSolver); }
static SymbolReference<ResolvedMethodDeclaration> solveMethod(String name, List<ResolvedType> parameterTypes, boolean staticOnly, TypeSolver typeSolver, ResolvedReferenceTypeDeclaration scopeType, Class clazz){ List<ResolvedMethodDeclaration> methods = new ArrayList<>(); Predicate<Method> staticOnlyCheck = m -> !staticOnly || (staticOnly && Modifier.isStatic(m.getModifiers())); for (Method method : clazz.getMethods()) { if (method.isBridge() || method.isSynthetic() || !method.getName().equals(name)|| !staticOnlyCheck.test(method)) continue; ResolvedMethodDeclaration methodDeclaration = new ReflectionMethodDeclaration(method, typeSolver); methods.add(methodDeclaration); } for (ResolvedReferenceType ancestor : scopeType.getAncestors()) { SymbolReference<ResolvedMethodDeclaration> ref = MethodResolutionLogic.solveMethodInType(ancestor.getTypeDeclaration(), name, parameterTypes, staticOnly); if (ref.isSolved()) { methods.add(ref.getCorrespondingDeclaration()); } } if (scopeType.getAncestors().isEmpty()){ ReferenceTypeImpl objectClass = new ReferenceTypeImpl(new ReflectionClassDeclaration(Object.class, typeSolver), typeSolver); SymbolReference<ResolvedMethodDeclaration> ref = MethodResolutionLogic.solveMethodInType(objectClass.getTypeDeclaration(), name, parameterTypes, staticOnly); if (ref.isSolved()) { methods.add(ref.getCorrespondingDeclaration()); } } return MethodResolutionLogic.findMostApplicable(methods, name, parameterTypes, typeSolver); }
static SymbolReference<ResolvedMethodDeclaration> solveMethod(String name, List<ResolvedType> parameterTypes, boolean staticOnly, TypeSolver typeSolver, ResolvedReferenceTypeDeclaration scopeType, Class clazz){ List<ResolvedMethodDeclaration> methods = new ArrayList<>(); Predicate<Method> staticOnlyCheck = m -> !staticOnly || (staticOnly && Modifier.isStatic(m.getModifiers())); for (Method method : clazz.getMethods()) { if (method.isBridge() || method.isSynthetic() || !method.getName().equals(name)|| !staticOnlyCheck.test(method)) continue; ResolvedMethodDeclaration methodDeclaration = new ReflectionMethodDeclaration(method, typeSolver); methods.add(methodDeclaration); } for (ResolvedReferenceType ancestor : scopeType.getAncestors()) { SymbolReference<ResolvedMethodDeclaration> ref = MethodResolutionLogic.solveMethodInType(ancestor.getTypeDeclaration(), name, parameterTypes, staticOnly, typeSolver); if (ref.isSolved()) { methods.add(ref.getCorrespondingDeclaration()); } } if (scopeType.getAncestors().isEmpty()){ ReferenceTypeImpl objectClass = new ReferenceTypeImpl(new ReflectionClassDeclaration(Object.class, typeSolver), typeSolver); SymbolReference<ResolvedMethodDeclaration> ref = MethodResolutionLogic.solveMethodInType(objectClass.getTypeDeclaration(), name, parameterTypes, staticOnly, typeSolver); if (ref.isSolved()) { methods.add(ref.getCorrespondingDeclaration()); } } return MethodResolutionLogic.findMostApplicable(methods, name, parameterTypes, typeSolver); }
public List<ResolvedReferenceType> getDirectAncestors() { // We need to go through the inheritance line and propagate the type parametes List<ResolvedReferenceType> ancestors = typeDeclaration.getAncestors(); ancestors = ancestors.stream() .map(a -> typeParametersMap().replaceAll(a).asReferenceType()) .collect(Collectors.toList()); // Avoid repetitions of Object ancestors.removeIf(a -> a.getQualifiedName().equals(Object.class.getCanonicalName())); boolean isClassWithSuperClassOrObject = this.getTypeDeclaration().isClass() && (this.getTypeDeclaration().asClass().getSuperClass() == null || !this.getTypeDeclaration().asClass().getSuperClass().getQualifiedName().equals(Object.class.getCanonicalName())); if (!isClassWithSuperClassOrObject) { ResolvedReferenceTypeDeclaration objectType = typeSolver.solveType(Object.class.getCanonicalName()); ResolvedReferenceType objectRef = create(objectType); ancestors.add(objectRef); } return ancestors; }
for (ResolvedReferenceType ancestor : typeDeclaration.getAncestors(true)) {
for(ResolvedReferenceType ancestor : scopeType.getAncestors()){ SymbolReference<ResolvedMethodDeclaration> ref = MethodResolutionLogic.solveMethodInType(ancestor.getTypeDeclaration(), name, argumentsTypes, typeSolver); if (ref.isSolved()){ if (scopeType.getAncestors().isEmpty()){ ReferenceTypeImpl objectClass = new ReferenceTypeImpl(new ReflectionClassDeclaration(Object.class, typeSolver), typeSolver); SymbolReference<ResolvedMethodDeclaration> ref = MethodResolutionLogic.solveMethodInType(objectClass.getTypeDeclaration(), name, argumentsTypes, typeSolver);
for(ResolvedReferenceType ancestor : scopeType.getAncestors()){ SymbolReference<ResolvedMethodDeclaration> ref = MethodResolutionLogic.solveMethodInType(ancestor.getTypeDeclaration(), name, argumentsTypes); if (ref.isSolved()){ if (scopeType.getAncestors().isEmpty()){ ReferenceTypeImpl objectClass = new ReferenceTypeImpl(new ReflectionClassDeclaration(Object.class, typeSolver), typeSolver); SymbolReference<ResolvedMethodDeclaration> ref = MethodResolutionLogic.solveMethodInType(objectClass.getTypeDeclaration(), name, argumentsTypes);
for(ResolvedReferenceType ancestor : scopeType.getAncestors()){ SymbolReference<ResolvedMethodDeclaration> ref = MethodResolutionLogic.solveMethodInType(ancestor.getTypeDeclaration(), name, argumentsTypes, typeSolver); if (ref.isSolved()){ if (scopeType.getAncestors().isEmpty()){ ReferenceTypeImpl objectClass = new ReferenceTypeImpl(new ReflectionClassDeclaration(Object.class, typeSolver), typeSolver); SymbolReference<ResolvedMethodDeclaration> ref = MethodResolutionLogic.solveMethodInType(objectClass.getTypeDeclaration(), name, argumentsTypes, typeSolver);
for (ResolvedReferenceType ancestor : typeDeclaration.getAncestors()) {
for (ResolvedReferenceType ancestor : typeDeclaration.getAncestors()) {
for (ResolvedReferenceType ancestor : declaration.getAncestors(true)) { try { for (ResolvedTypeDeclaration internalTypeDeclaration : ancestor.getTypeDeclaration().internalTypes()) {
for (ResolvedReferenceType ancestor : this.typeDeclaration.getAncestors()) { try { for (ResolvedTypeDeclaration internalTypeDeclaration : ancestor.getTypeDeclaration().internalTypes()) {
for (ResolvedReferenceType ancestor : this.typeDeclaration.getAncestors()) { try { for (ResolvedTypeDeclaration internalTypeDeclaration : ancestor.getTypeDeclaration().internalTypes()) {