@Nonnull
	private static int[] computeNewlineOffsets(@Nonnull String text) {
		// Find existing newline offsets.
		int[] offsets = StringUtil.indicesOf(text, '\n');

		int textLength = text.length();
		if (offsets.length == 0) {
			// Base cases for strings without newlines.
			return text.isEmpty() ? new int[]{0} : new int[]{0, textLength};
		} else {
			// Ensure we start with a newline offset.
			if (offsets[0] != 0) {
				int[] newOffsets = new int[offsets.length + 1];
				newOffsets[0] = 0;
				System.arraycopy(offsets, 0, newOffsets, 1, offsets.length);
				offsets = newOffsets;
			}

			// Ensure we end with a newline offset.
			if (offsets[offsets.length - 1] != textLength - 1) {
				int[] newOffsets = new int[offsets.length + 1];
				newOffsets[offsets.length] = textLength;
				System.arraycopy(offsets, 0, newOffsets, 0, offsets.length);
				offsets = newOffsets;
			}
		}

		return offsets;
	}
@param text
		Text to scan.

@return Offsets of newline separators, with included cases for the start and end of
the string even if {@code "\n"} does not prefix or suffix the string.
recaf-core/src/main/java/software/coley/recaf/util/StringDiff.java