use of javassist.expr.FieldAccess in project reflections by ronmamo.
the class MemberUsageScanner method scanMember.
private void scanMember(CtBehavior member, List<Map.Entry<String, String>> entries) throws CannotCompileException {
// key contains this$/val$ means local field/parameter closure
final String key = member.getDeclaringClass().getName() + "." + member.getMethodInfo().getName() + "(" + parameterNames(member.getMethodInfo()) + // + " #" + member.getMethodInfo().getLineNumber(0)
")";
member.instrument(new ExprEditor() {
@Override
public void edit(NewExpr e) {
try {
add(entries, e.getConstructor().getDeclaringClass().getName() + "." + "<init>" + "(" + parameterNames(e.getConstructor().getMethodInfo()) + ")", key + " #" + e.getLineNumber());
} catch (NotFoundException e1) {
throw new ReflectionsException("Could not find new instance usage in " + key, e1);
}
}
@Override
public void edit(MethodCall m) {
try {
add(entries, m.getMethod().getDeclaringClass().getName() + "." + m.getMethodName() + "(" + parameterNames(m.getMethod().getMethodInfo()) + ")", key + " #" + m.getLineNumber());
} catch (NotFoundException e) {
throw new ReflectionsException("Could not find member " + m.getClassName() + " in " + key, e);
}
}
@Override
public void edit(ConstructorCall c) {
try {
add(entries, c.getConstructor().getDeclaringClass().getName() + "." + "<init>" + "(" + parameterNames(c.getConstructor().getMethodInfo()) + ")", key + " #" + c.getLineNumber());
} catch (NotFoundException e) {
throw new ReflectionsException("Could not find member " + c.getClassName() + " in " + key, e);
}
}
@Override
public void edit(FieldAccess f) {
try {
add(entries, f.getField().getDeclaringClass().getName() + "." + f.getFieldName(), key + " #" + f.getLineNumber());
} catch (NotFoundException e) {
throw new ReflectionsException("Could not find member " + f.getFieldName() + " in " + key, e);
}
}
});
}
Aggregations