}
}
}
protected static IProgramElement getNode(AsmManager model, Shadow shadow) {
Member enclosingMember = shadow.getEnclosingCodeSignature();
// This variant will not be tricked by ITDs that would report they are
// in the target type already.
// This enables us to discover the ITD declaration (in the aspect) and
// advise it appropriately.
// Have to be smart here, for a code node within an ITD we want to
// lookup the declaration of the
// ITD in the aspect in order to add the code node at the right place -
// and not lookup the
// ITD as it applies in some target type. Due to the use of
// effectiveSignature we will find
// that shadow.getEnclosingCodeSignature() will return a member
// representing the ITD as it will
// appear in the target type. So here, we do an extra bit of analysis to
// make sure we
// do the right thing in the ITD case.
IProgramElement enclosingNode = null;
if (shadow instanceof BcelShadow) {
Member actualEnclosingMember = ((BcelShadow) shadow).getRealEnclosingCodeSignature();
if (actualEnclosingMember == null) {
enclosingNode = lookupMember(model.getHierarchy(), shadow.getEnclosingType(), enclosingMember);
} else {
UnresolvedType type = enclosingMember.getDeclaringType();
UnresolvedType actualType = actualEnclosingMember.getDeclaringType();
// if these are not the same, it is an ITD and we need to use
// the latter to lookup
if (type.equals(actualType)) {
enclosingNode = lookupMember(model.getHierarchy(), shadow.getEnclosingType(), enclosingMember);
} else {
enclosingNode = lookupMember(model.getHierarchy(), shadow.getEnclosingType(), actualEnclosingMember);
}
}
} else {
enclosingNode = lookupMember(model.getHierarchy(), shadow.getEnclosingType(), enclosingMember);
}
if (enclosingNode == null) {
Lint.Kind err = shadow.getIWorld().getLint().shadowNotInStructure;
if (err.isEnabled()) {
err.signal(shadow.toString(), shadow.getSourceLocation());
}
return null;
}
Member shadowSig = shadow.getSignature();
// pr235204
if (shadow.getKind() == Shadow.MethodCall || shadow.getKind() == Shadow.ConstructorCall
|| !shadowSig.equals(enclosingMember)) {
IProgramElement bodyNode = findOrCreateCodeNode(model, enclosingNode, shadowSig, shadow);
return bodyNode;
} else {
return enclosingNode;
}