BitSet (@NotNull Editor editor, @NotNull CharSequence text, @NotNull TextRange range, int indexesOffset) { HighlighterIterator iterator = editor.getHighlighter().createIterator(range.getStartOffset()); int rangeEnd = range.getEndOffset(); BitSet locations = new BitSet(range.getLength()); int pos; while (!iterator.atEnd() && (pos = iterator.getStart()) < rangeEnd) { if (text.charAt(pos) == '\\' && (pos + 1 >= rangeEnd || text.charAt(pos + 1) != '\\') && pos >= indexesOffset) { locations.set(pos - indexesOffset); } iterator.advance(); } return locations; }