boolean updateReference(Reference editRef, CodeUnit fromCodeUnit, Address toAddr,
			boolean isOffsetRef, long offset, RefType refType) {
		CompoundCmd<Program> cmd = new CompoundCmd<>("Update Memory Reference");
		int opIndex = editRef.getOperandIndex();
		cmd.add(new RemoveReferenceCmd(editRef));
		if (isOffsetRef) {
			cmd.add(new AddOffsetMemRefCmd(fromCodeUnit.getMinAddress(), toAddr, false, refType,
				SourceType.USER_DEFINED, opIndex, offset));
		}
		else {
			cmd.add(new AddMemRefCmd(fromCodeUnit.getMinAddress(), toAddr, refType,
				SourceType.USER_DEFINED, opIndex, editRef.isPrimary()));
		}
		return tool.execute(cmd, fromCodeUnit.getProgram());
	}
Update memory reference

@return true if update was successful
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/references/ReferencesPlugin.java