allBehaviours.add(ctBehavior);
}
final IntHolder replaced = new IntHolder();
for (CtBehavior ctBehavior_ : allBehaviours) {
final Map<Integer, String> newExprType = new HashMap<Integer, String>();
ctBehavior_.instrument(new ExprEditor() {
NewExpr lastNewExpr;
int newPos = 0;
@Override
public void edit(NewExpr e) {
lastNewExpr = null;
newPos++;
try {
if (classPool.get(e.getClassName()).subtypeOf(ctField.getType())) {
lastNewExpr = e;
}
} catch (NotFoundException ignored) {
}
}
@Override
public void edit(FieldAccess e) {
NewExpr myLastNewExpr = lastNewExpr;
lastNewExpr = null;
if (myLastNewExpr != null && e.getFieldName().equals(field)) {
newExprType.put(newPos, classSignatureToName(e.getSignature()));
}
}
@Override
public void edit(MethodCall e) {
lastNewExpr = null;
}
@Override
public void edit(NewArray e) {
lastNewExpr = null;
}
@Override
public void edit(Cast e) {
lastNewExpr = null;
}
@Override
public void edit(Instanceof e) {
lastNewExpr = null;
}
@Override
public void edit(Handler e) {
lastNewExpr = null;
}
@Override
public void edit(ConstructorCall e) {
lastNewExpr = null;
}
});
ctBehavior_.instrument(new ExprEditor() {
int newPos = 0;
@Override
public void edit(NewExpr e) throws CannotCompileException {
newPos++;