private void removeVariableRefs(Function function, AddressSetView view) {
		ReferenceManager refMgr = program.getReferenceManager();
		AddressIterator iter = refMgr.getReferenceSourceIterator(view, true);
		while (iter.hasNext()) {
			Address fromAddr = iter.next();
			Reference[] refs = refMgr.getReferencesFrom(fromAddr);
			for (Reference ref : refs) {
				Address toAddr = ref.getToAddress();
				if (toAddr.isStackAddress() || toAddr.isRegisterAddress()) {
					// delete all stack and register references
					refMgr.delete(ref);
				}
				else {
					long symID = ref.getSymbolID();
					if (symID >= 0) {
						Symbol s = symbolMgr.getSymbol(symID);
						if (s instanceof VariableSymbolDB &&
							s.getParentSymbol().getID() == function.getID()) {
							if (toAddr.isMemoryAddress()) {
								// leave memory references in place
								refMgr.removeAssociation(ref);
							}
							else {
								// delete bound register references
								refMgr.delete(ref);
							}
						}
					}
				}
			}
		}
	}
Remove variable references in the given address set.
Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/function/FunctionManagerDB.java