@Override
	public void actionPerformed(ListingActionContext context) {
		Address entry = null;
		AddressSetView body = null;

		if (context.hasSelection()) {
			body = context.getSelection();
			entry = body.getMinAddress();
		}
		else {
			entry = context.getAddress();
		}

		if (entry == null) {
			return;
		}

		String name = null;
		Function func = context.getProgram().getFunctionManager().getFunctionContaining(entry);
		if (func != null && func.getEntryPoint().equals(entry)) {
			if (createThunk) {
				Msg.showError(this, null, "Thunk Conflict",
					"Thunk function conflicts with an existing function!");
				return;
			}
			funcPlugin.getTool().setStatusInfo("Function \"" + func.getName() + "\" at " +
				func.getEntryPoint() + " already exists");
			int result = OptionDialog.showOptionNoCancelDialog(null,
				"Function Already Exists at This Location",
				"Function \"" + func.getName() + "\" at " + func.getEntryPoint() +
					" already exists at this location.\n" +
					"Are you sure you want to proceed?\nDoing so, will cause analysis to be re-run on this function",
				createThunk ? "Create Thunk" : "&Re-create", "&No", OptionDialog.QUESTION_MESSAGE);
			if (result != OptionDialog.OPTION_ONE) {
				return;
			}
			funcPlugin.getTool().clearStatusInfo();
		}

		BackgroundCommand<Program> cmd;
		if (createThunk) {
			cmd = getCreateThunkFunctionCmd(context.getProgram(), entry, body);
			if (cmd == null) {
				return; // cancelled
			}
		}
		else {
			cmd = new CreateFunctionCmd(name, entry, body, SourceType.USER_DEFINED, allowExisting,
				allowExisting);
		}
		funcPlugin.execute(context.getProgram(), cmd);
	}
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