string_regex_marker.rb 441 Bytes
Newer Older
1 2
# frozen_string_literal: true

3 4
module Gitlab
  class StringRegexMarker < StringRangeMarker
5
    # rubocop: disable CodeReuse/ActiveRecord
6
    def mark(regex, group: 0, &block)
7
      ranges = []
8

9 10
      raw_line.scan(regex) do
        begin_index, end_index = Regexp.last_match.offset(group)
11

12 13 14 15
        ranges << (begin_index..(end_index - 1))
      end

      super(ranges, &block)
16
    end
17
    # rubocop: enable CodeReuse/ActiveRecord
18 19
  end
end