private boolean confirmPossibleReferenceRemoval(CodeUnit fromCodeUnit, int opIndex,
			Reference oldRef) {

		if (oldRef == null) {
			Reference[] refs = fromCodeUnit.getProgram().getReferenceManager().getReferencesFrom(
				fromCodeUnit.getMinAddress(), opIndex);
			if (refs.length != 0) {
				oldRef = refs[0];
			}
			else {
				return true;
			}
		}

		String curType;
		if (oldRef.isStackReference()) {
			curType = "Stack reference";
		}
		else if (oldRef.getToAddress().isRegisterAddress()) {
			curType = "Register reference";
		}
		else if (oldRef.isExternalReference()) {
			curType = "External reference";
		}
		else {
			curType = "Memory reference(s)";
		}

		JComponent parent = editRefDialog.getComponent();
		int choice = OptionDialog.showOptionDialog(parent, "Reference Removal Confirmation",
			"Warning! existing " + curType + " will be removed.", "Continue",
			OptionDialog.WARNING_MESSAGE);
		return (choice != OptionDialog.CANCEL_OPTION);
	}
Add memory reference

@param fromCodeUnit
@param opIndex
@param toAddr
@param isOffsetRef
@param offset
@param refType
@return true if add was successful
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/references/ReferencesPlugin.java