private CreateThunkFunctionCmd getCreateThunkFunctionCmd(Program program, Address entry,
			AddressSetView body) {

		Symbol refSymbol = null;
		Address refAddr = null;

		Listing listing = program.getListing();
		ReferenceManager refMgr = program.getReferenceManager();
		Instruction instr = listing.getInstructionAt(entry);
		if (instr != null && instr.getFlowType().isJump()) {
			Reference indirectRef = null;
			Reference dataRef = null;
			Reference jumpRef = null;
			for (Reference ref : instr.getReferencesFrom()) {
				RefType refType = ref.getReferenceType();
				if (refType == RefType.INDIRECTION) {
					indirectRef = ref;
				}
				else if (refType.isData()) {
					dataRef = ref;
				}
				else if (refType.isJump()) {
					jumpRef = ref;
				}
			}
			if (jumpRef != null) {
				refAddr = jumpRef.getToAddress();
			}
			else if (instr.getFlowType().isComputed()) {
				Reference ref = indirectRef != null ? indirectRef : dataRef;
				if (ref != null) {
					// find indirect destination
					Reference[] refs = refMgr.getReferencesFrom(ref.getToAddress());
					if (refs.length != 0) {
						if (refs[0].isExternalReference()) {
							ExternalLocation extLoc =
								((ExternalReference) refs[0]).getExternalLocation();
							refSymbol = extLoc.getSymbol();
							refAddr = extLoc.getAddress();
						}
						else if (refs[0].isMemoryReference()) {
							refAddr = refs[0].getToAddress();
						}
					}
				}
			}
		}
		else if (body == null || body.getNumAddresses() == 0) {
			Msg.showError(this, funcPlugin.getTool().getActiveWindow(),
				"Create Thunk Function Failed", "Must select thunk function body");
			return null;
		}
		else {
			CodeUnit cu = listing.getCodeUnitAt(entry);
			if (cu != null && new AddressSet(cu.getMinAddress(), cu.getMaxAddress()).equals(body)) {
				Reference ref = cu.getPrimaryReference(0);
				if (ref != null) {
					refAddr = ref.getToAddress();
				}
			}
		}

		if (refSymbol == null && refAddr != null) {
			refSymbol = program.getSymbolTable().getPrimarySymbol(refAddr);
		}

		ThunkReferenceAddressDialog dialog = new ThunkReferenceAddressDialog(funcPlugin.getTool());
		if (refSymbol != null) {
			dialog.showDialog(program, entry, refSymbol);
		}
		else {
			dialog.showDialog(program, entry, refAddr);
		}
		refSymbol = dialog.getSymbol();
		refAddr = dialog.getAddress();

		if (refSymbol != null) {
			return new CreateThunkFunctionCmd(entry, body, refSymbol);
		}
		else if (refAddr != null) {
			return new CreateThunkFunctionCmd(entry, body, refAddr);
		}
		return null;
	}
Method called when the action is invoked.
@param ActionEvent details regarding the invocation of this action
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/function/CreateFunctionAction.java