@Override
	public boolean isAddToPopup(ActionContext context) {
		CodeUnit cu = getCodeUnit(context);
		if (cu == null || !isApplicableToUnit(cu)) {
			return false;
		}

		ListingActionContext lac = (ListingActionContext) context;

		ComponentProvider provider = lac.getComponentProvider();
		if (!(provider instanceof CodeViewerProvider codeViewer)) {
			return false;
		}

		if (codeViewer.isReadOnly()) {
			return false;
		}

		Program program = lac.getProgram();
		if (program == null) {
			return false;
		}

		Address address = lac.getAddress();
		if (address == null) {
			return false;
		}
		MemoryBlock block = program.getMemory().getBlock(address);
		if (block == null || !block.isInitialized()) {
			return false;
		}
		return true;
	}
Check if the action is applicable to the given code unit

@param unit the code unit at the user's cursor
@return true if applicable, false if not
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/assembler/AbstractPatchAction.java