use of spoon.reflect.declaration.CtFormalTypeDeclarer in project spoon by INRIA.
the class CtTypeParameterReferenceImpl method getDeclaration.
@Override
public CtTypeParameter getDeclaration() {
if (!isParentInitialized()) {
return null;
}
CtElement e = this;
CtElement parent = getParent();
if (parent instanceof CtTypeReference) {
if (parent.isParentInitialized() == false) {
return null;
}
parent = parent.getParent();
}
if (parent instanceof CtExecutableReference) {
CtExecutableReference parentExec = (CtExecutableReference) parent;
if (!parentExec.getDeclaringType().equals(e)) {
CtElement parent2 = parentExec.getExecutableDeclaration();
if (parent2 instanceof CtMethod) {
e = parent2;
} else {
e = e.getParent(CtFormalTypeDeclarer.class);
}
} else {
e = e.getParent(CtFormalTypeDeclarer.class);
}
} else {
e = e.getParent(CtFormalTypeDeclarer.class);
}
// collecting all formal type declarers of the hierarchy
while (e != null) {
CtTypeParameter result = findTypeParamDeclaration((CtFormalTypeDeclarer) e, this.getSimpleName());
if (result != null) {
return result;
}
e = e.getParent(CtFormalTypeDeclarer.class);
}
return null;
}
Aggregations