use of com.github.javaparser.resolution.types.ResolvedReferenceType in project javaparser by javaparser.
the class JavassistInterfaceDeclaration method getAncestors.
@Override
public List<ResolvedReferenceType> getAncestors() {
List<ResolvedReferenceType> ancestors = new ArrayList<>();
try {
for (CtClass interfaze : ctClass.getInterfaces()) {
ResolvedReferenceType superInterfaze = JavassistFactory.typeUsageFor(interfaze, typeSolver).asReferenceType();
ancestors.add(superInterfaze);
}
} catch (NotFoundException e) {
throw new RuntimeException(e);
}
ancestors = ancestors.stream().filter(a -> a.getQualifiedName() != Object.class.getCanonicalName()).collect(Collectors.toList());
ancestors.add(new ReferenceTypeImpl(typeSolver.solveType(Object.class.getCanonicalName()), typeSolver));
return ancestors;
}
use of com.github.javaparser.resolution.types.ResolvedReferenceType in project javaparser by javaparser.
the class ReflectionClassAdapter method getAncestors.
public List<ResolvedReferenceType> getAncestors() {
List<ResolvedReferenceType> ancestors = new LinkedList<>();
if (getSuperClass() != null) {
ReferenceTypeImpl superClass = getSuperClass();
ancestors.add(superClass);
} else {
ReferenceTypeImpl object = new ReferenceTypeImpl(new ReflectionClassDeclaration(Object.class, typeSolver), typeSolver);
ancestors.add(object);
}
ancestors.addAll(getInterfaces());
for (int i = 0; i < ancestors.size(); i++) {
ResolvedReferenceType ancestor = ancestors.get(i);
if (ancestor.hasName() && ancestor.getQualifiedName().equals(Object.class.getCanonicalName())) {
ancestors.remove(i);
i--;
}
}
return ancestors;
}
use of com.github.javaparser.resolution.types.ResolvedReferenceType in project javaparser by javaparser.
the class AbstractClassDeclaration method getAllInterfaces.
@Override
public final List<ResolvedReferenceType> getAllInterfaces() {
List<ResolvedReferenceType> interfaces = new ArrayList<>();
for (ResolvedReferenceType interfaceDeclaration : getInterfaces()) {
interfaces.add(interfaceDeclaration);
interfaces.addAll(interfaceDeclaration.getAllInterfacesAncestors());
}
ResolvedReferenceType superClass = this.getSuperClass();
if (superClass != null) {
interfaces.addAll(superClass.getAllInterfacesAncestors());
}
return interfaces;
}
use of com.github.javaparser.resolution.types.ResolvedReferenceType in project javaparser by javaparser.
the class AbstractClassDeclaration method getAllSuperClasses.
@Override
public final List<ResolvedReferenceType> getAllSuperClasses() {
List<ResolvedReferenceType> superclasses = new ArrayList<>();
ResolvedReferenceType superClass = getSuperClass();
if (superClass != null) {
superclasses.add(superClass);
superclasses.addAll(superClass.getAllClassesAncestors());
}
if (superclasses.removeIf(s -> s.getQualifiedName().equals(Object.class.getCanonicalName()))) {
superclasses.add(object());
}
return superclasses;
}
use of com.github.javaparser.resolution.types.ResolvedReferenceType in project javaparser by javaparser.
the class AbstractTypeDeclaration method getAllMethods.
@Override
public final Set<MethodUsage> getAllMethods() {
Set<MethodUsage> methods = new HashSet<>();
Set<String> methodsSignatures = new HashSet<>();
for (ResolvedMethodDeclaration methodDeclaration : getDeclaredMethods()) {
methods.add(new MethodUsage(methodDeclaration));
methodsSignatures.add(methodDeclaration.getSignature());
}
for (ResolvedReferenceType ancestor : getAllAncestors()) {
for (MethodUsage mu : ancestor.getDeclaredMethods()) {
String signature = mu.getDeclaration().getSignature();
if (!methodsSignatures.contains(signature)) {
methodsSignatures.add(signature);
methods.add(mu);
}
}
}
return methods;
}
Aggregations