@Override
	protected DataTypeComponent insert(int rowIndex, DataType dataType, int length, String name,
			String comment) throws InvalidDataTypeException {
		checkIsAllowableDataType(dataType);
		try {
			return viewDTM.withTransaction("Insert Component", () -> {
				DataTypeComponent dtc;
				if (isPackingEnabled() || !(dataType instanceof BitFieldDataType)) {
					dtc = viewComposite.insert(rowIndex, dataType, length, name, comment);
				}
				else {
					BitFieldDataType bitfield = (BitFieldDataType) dataType;
					dtc = viewComposite.insertBitField(rowIndex, length, bitfield.getBitOffset(),
						bitfield.getBaseDataType(), bitfield.getDeclaredBitSize(), name, comment);
				}
				if (rowIndex <= currentEditRow) {
					currentEditRow++;
				}
				adjustSelection(rowIndex, 1);
				// Consume undefined bytes that may have been added, if needed.
				consumeByComponent(rowIndex - 1);

				return dtc;
			});
		}
		catch (IllegalArgumentException exc) {
			throw new InvalidDataTypeException(exc.getMessage());
		}
	}
Returns the number of bytes that are included in the current selection
range.

@param range the range of indices for the component's whose sizes should
be added together.
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/StructureEditorModel.java