// instead of cloning it
newFunc.setBody(dupMethod.getBody());
// also copy the parameters from the old function
newFunc.getParameters().addAll(dupMethod.getParameters());
// add the new function to the top level list of statements
fragment.getStatements().add(newFunc.makeStmt());
newNamesByHoistedFunction.put(dupMethod, newName);
}
ReplaceDuplicateInvocationNameRefs rdup = new ReplaceDuplicateInvocationNameRefs(
dfbr.getDuplicateMap(), dfbr.getBlacklist(), dupMethodMap, newNamesByHoistedFunction);