private AddressSet getDefinedData(ProgramLocationActionContext context,
			AddressSetView startSet, TaskMonitor taskMonitor) {

		Program program = context.getProgram();
		Listing listing = program.getListing();
		AddressSet addressSet = new AddressSet();
		long numDefined = listing.getNumDefinedData(); // Get the total number since we can't easily get the number in the selection.
		taskMonitor.initialize((int) numDefined);
		int counter = 0;
		DataIterator diter = listing.getDefinedData(startSet, true);
		while (diter.hasNext() && !taskMonitor.isCancelled()) {
			counter++;
			taskMonitor.setProgress(counter);
			Data data = diter.next();
			addressSet.addRange(data.getMinAddress(), data.getMaxAddress());
		}
		return addressSet;
	}
<code>getDefinedData</code> returns the defined data associated with the selection
or with the program if there isn't a selection.

@param taskMonitor The task monitor that will monitor task progress.
@return AddressSet the defined data address set.
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/select/qualified/QualifiedSelectionPlugin.java