private void encodeCommentsType(Encoder encoder, AddressSetView addrset, Address addr,
			CommentType commenttype) throws IOException {
		String typename;
		switch (commenttype) {
			case EOL:
				typename = "user1";
				break;
			case PRE:
				typename = "user2";
				break;
			case POST:
				typename = "user3";
				break;
			case PLATE:
				typename = "header";
				break;
			default:
				typename = "";
				break;
		}
		AddressIterator iter = listing.getCommentAddressIterator(commenttype, addrset, true);
		while (iter.hasNext()) {
			Address commaddr = iter.next();
			String text = listing.getComment(commenttype, commaddr);
			if (text != null) {
				if (commenttype == CommentType.PLATE) {
					// Plate comments on the function entry
					// address are considered part of the header
					if (commaddr.equals(addr)) {
						continue;
					}
				}
				encoder.openElement(ELEM_COMMENT);
				encoder.writeString(ATTRIB_TYPE, typename);
				AddressXML.encode(encoder, addr);
				AddressXML.encode(encoder, commaddr);
				encoder.openElement(ELEM_TEXT);
				encoder.writeString(ATTRIB_CONTENT, text);
				encoder.closeElement(ELEM_TEXT);
				encoder.closeElement(ELEM_COMMENT);
			}
		}

	}
Encode comments of a specific type to stream for a given address set.  Comments are
collected from the listing.  The encoding associates the comment both with the address where
it was placed, but also with the (entry point) address of the function containing it.
Plate comments whose address matches the function entry point are not encoded.

@param encoder is the stream encoder
@param addrset is the address set over which to search
@param addr is the entry point of the function
@param commenttype is the type of comment
@throws IOException for errors in the underlying stream
Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/DecompileCallback.java