List<String> (@NotNull CharSequence text, @NonNls LineOffsets lineOffsets, int startLine, int endLine) { if (startLine < 0 || startLine > endLine || endLine > lineOffsets.getLineCount()) { throw new IndexOutOfBoundsException(String.format("Wrong line range: [%d, %d); lineCount: '%d'", startLine, endLine, lineOffsets.getLineCount())); } List<String> result = new ArrayList<>(); for (int i = startLine; i < endLine; i++) { int start = lineOffsets.getLineStart(i); int end = lineOffsets.getLineEnd(i); result.add(text.subSequence(start, end).toString()); } return result; }