private void clearCodeUnits(AddressRange range) throws CancelledException {

		Listing listing = program.getListing();

		boolean clearContext = options.shouldClear(REGISTERS);
		AddressRangeChunker chunker = new AddressRangeChunker(range, 10000);
		for (AddressRange chunk : chunker) {

			Address min = chunk.getMinAddress();
			Address max = chunk.getMaxAddress();

			monitor.setMessage("Clearing code at " + min);

			listing.clearCodeUnits(min, max, clearContext, monitor);

			int numDone = (int) (max.subtract(min) + 1);
			monitor.incrementProgress(numDone);

			// Allow the Swing thread a chance to paint components that may require a DB lock
			Swing.allowSwingToProcessEvents();
		}
	}
Clears over the given range, <b>clearing only code</b>.  To clear other items,
use {@link #ClearCmd(AddressSetView,ClearOptions)}.

@param view the addresses over which to clear
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/clear/ClearCmd.java