String derivedCalleeName = inferences.getDerivedCalleeNameForCallId(callNode.getId());
if (derivedCalleeName != null) {
// Creates a new call node, but with a different target name.
// TODO: Create a CallNode.withNewName() convenience method.
CallNode newCallNode;
if (callNode instanceof CallBasicNode) {
// For simplicity, use the full callee name as the source callee name.
newCallNode = new CallBasicNode(
callNode.getId(), derivedCalleeName, derivedCalleeName, false,
callNode.isPassingData(), callNode.isPassingAllData(), callNode.getDataExpr(),
callNode.getUserSuppliedPlaceholderName(), callNode.getSyntaxVersion(),
callNode.getEscapingDirectiveNames());
} else {
CallDelegateNode callNodeCast = (CallDelegateNode) callNode;
newCallNode = new CallDelegateNode(
callNode.getId(), derivedCalleeName, callNodeCast.getDelCalleeVariantExpr(), false,
callNodeCast.allowsEmptyDefault(), callNode.isPassingData(),
callNode.isPassingAllData(), callNode.getDataExpr(),
callNode.getUserSuppliedPlaceholderName(),
callNode.getEscapingDirectiveNames());
}
if (!callNode.getCommandText().equals(newCallNode.getCommandText())) {
newCallNode.setSourceLocation(callNode.getSourceLocation());
moveChildrenTo(callNode, newCallNode);
replaceChild(callNode, newCallNode);
}
// Ensure we visit the new node instead of the old one.
callNode = newCallNode;