public boolean isCreateFunctionAllowed(ListingActionContext context, boolean allowExisting,
			boolean createThunk) {
		// Debugger traces do not support functions
		if (context.getNavigatable().isDynamic()) {
			return false;
		}
		// A program and location is needed for any create function action.
		Program program = context.getProgram();
		if (program == null) {
			return false;
		}

		ProgramLocation location = context.getLocation();
		if (location == null) {
			return false;
		}

		Address addr = location.getAddress();
		if (addr == null) {
			return false;
		}

		boolean cursorIsInSelection = false;
		ProgramSelection selection = context.getSelection();
		if (selection != null && !selection.isEmpty()) {
			//**** NOTE: the minimum address of the selection is used as the entry point
			//****       to the function.  The current cursor location could be used
			//****       as the entry, but that might be confusing
			addr = selection.getMinAddress();
			cursorIsInSelection = true;
		}

		// can't create a function on a function
		Function func = program.getListing().getFunctionAt(addr);
		if ((func == null && !allowExisting) ||
			(func != null && allowExisting && !func.isThunk())) {
			// If we have a selection, don't enable the selection if the cursor is
			// not in the selection.
			if (cursorIsInSelection) {
				return true;
			}
			else if (program.getListing().getInstructionContaining(addr) != null) {
				return true;
			}
		}
		return false;
	}
Get an iterator over all functions overlapping the current selection.
If there is no selection any functions overlapping the current location.

@param context the context 
@return Iterator over functions
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/function/FunctionPlugin.java