void (String oldName, String newName, ChainContext context) { int idx = ArrayUtil.indexOf(myParameters, newName); if(idx >= 0) { // If new name collides with existing parameter, rename it for(int i = 1;; i++) { String paramName = newName+'$'+i; if (!paramName.equals(oldName) && !StreamEx.of(myParameters).has(paramName) && !hasVarReference(myBody, paramName, context)) { myBody = replaceVarReference(myBody, newName, paramName, context); myParameters[idx] = paramName; break; } } } myBody = replaceVarReference(myBody, oldName, newName, context); }