private static void restoreReference(DataType newType, ReferenceManager refMgr, Reference ref) {

		if (ref == null) {
			return;
		}

		if (!(newType instanceof Pointer)) {
			return;
		}

		// if this was a pointer and had an external reference, put it back!
		ExternalLocation extLoc = ((ExternalReference) ref).getExternalLocation();
		Address fromAddress = ref.getFromAddress();
		SourceType source = ref.getSource();
		RefType type = ref.getReferenceType();
		try {
			refMgr.addExternalReference(fromAddress, 0, extLoc, source, type);
		}
		catch (InvalidInputException e) {
			throw new AssertException(e);
		}
	}
Create data where existing data may already exist.
@param program the program
@param addr data address (offcut data address only allowed if clearMode == ClearDataMode.CLEAR_ALL_CONFLICT_DATA)
@param newType new data-type being applied
@param length data length (used only for Dynamic newDataType which has canSpecifyLength()==true)
@param stackPointers see {@link #reconcileAppliedDataType(DataType, DataType, boolean)}
@param clearMode see CreateDataMode
@return new data created
@throws CodeUnitInsertionException if data creation failed
Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/data/DataUtilities.java