public void computeMetric(TestabilityContext context, MethodInfo currentMethod) {
if (context.isClassWhiteListed(clazzName)) {
return;
}
try {
MethodInfo toMethod = context.getMethod(clazzName, name + signature);
if (context.methodAlreadyVisited(toMethod)) {
// Method already counted, skip (to prevent recursion)
} else if (toMethod.canOverride() && context.isInjectable(methodThis)) {
// Method can be overridden / injectable
} else {
// Method can not be intercepted we have to add the cost
// recursively
if (toMethod.isInstance()) {
context.localAssignment(toMethod, getLineNumber(), toMethod
.getMethodThis(), methodThis);
}
int i = 0;
if (parameters.size() != toMethod.getParameters().size()) {
throw new IllegalStateException(
"Argument count does not match method parameter count.");
}
for (Variable var : parameters) {
context.localAssignment(toMethod, getLineNumber(), toMethod
.getParameters().get(i++), var);
}
context.recordMethodCall(currentMethod, getLineNumber(), toMethod);
context.localAssignment(toMethod, getLineNumber(), returnValue,
context.getReturnValue());