public void replaceReferences(AddressSetView originAddressSet, boolean onlyKeepDefaults,
			TaskMonitor monitor) throws CancelledException, UnsupportedOperationException {

		if (!originToResultTranslator.isOneForOneTranslator()) {
			String message = originToResultTranslator.getClass().getName() +
				" is not a one for one translator and can't replace references.";
			throw new UnsupportedOperationException(message);
		}
		monitor.setMessage("Replacing References...");
		if (originAddressSet.isEmpty()) {
			return;
		}
		AddressSet resultAddressSet = originToResultTranslator.getAddressSet(originAddressSet);

		ReferenceManager originRM = originProgram.getReferenceManager();
		ReferenceManager resultRM = resultProgram.getReferenceManager();
		AddressIterator originIter = originRM.getReferenceSourceIterator(originAddressSet, true);
		AddressIterator resultIter = resultRM.getReferenceSourceIterator(resultAddressSet, true);
		AddressIteratorConverter convertedResultIter =
			new AddressIteratorConverter(resultProgram, resultIter, originProgram);
		// Determine where to get the new code units from.
		MultiAddressIterator originRefAddrIter =
			new MultiAddressIterator(new AddressIterator[] { convertedResultIter, originIter });
		for (long count = 0; originRefAddrIter.hasNext() && !monitor.isCancelled(); count++) {
			monitor.checkCancelled();
			Address originAddress = originRefAddrIter.next();
			if (count == PROGRESS_COUNTER_GRANULARITY) {
				monitor.setMessage("Replacing References...   " + originAddress.toString(true));
				count = 0;
			}
			replaceRefs(originAddress, onlyKeepDefaults);
		}
	}
<CODE>replaceReferences</CODE> replaces all references in
program1 for the specified address set with the references from program2.
If an equivalent reference already exists then it is updated to match the
new reference.
<br> Note: All reference types (memory, stack, external) get replaced
where possible. i.e. If a function or variable doesn't exist for a
variable reference then it will not be able to replace the reference.

@param originAddressSet the addresses to be merged.
The addresses in this set should be derived from the origin program.
@param onlyKeepDefaults true indicates to replace all references with only
the default references from the origin program.
@param monitor the task monitor for notifying the user of this merge's
progress.
@throws CancelledException if the user cancels the replace via the monitor.
@throws UnsupportedOperationException if the ProgramMerge translators are not
"one for one translators".
Ghidra/Features/Base/src/main/java/ghidra/program/util/ProgramMerge.java