Create a new syntactic item by replacing all occurrences of one item ( from ) with another ( to ). In the case that there is no change to the item (or any of its children) then the original item is returned untouched. Specifically, the exact same reference will be returned.
(Item item, Item from, Item to)
| 409 | * @return |
| 410 | */ |
| 411 | public static Item substitute(Item item, Item from, Item to) { |
| 412 | Item nItem = substitute(item, from, to, new IdentityHashMap<>()); |
| 413 | if(nItem != item) { |
| 414 | item.getHeap().allocate(nItem); |
| 415 | } |
| 416 | return nItem; |
| 417 | } |
| 418 | |
| 419 | /** |
| 420 | * Helper method for above. |