void clear(ClearOptions options, ListingActionContext context) {
		if (!options.clearAny()) {
			return;
		}

		if (!scheduleClear(options, context)) {
			return;
		}

		AddressSet set = new AddressSet(context.getSelection());
		ClearCmd cmd = new ClearCmd(set, options);
		tool.executeBackgroundCommand(cmd, context.getProgram());
	}
Plugin that manages the 'clear' and 'clear with options' operations on a program.
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/clear/ClearPlugin.java