2018-10-22 03:00:50 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-07-10 16:17:20 -04:00
|
|
|
module Gitlab
|
|
|
|
class StringRegexMarker < StringRangeMarker
|
|
|
|
def mark(regex, group: 0, &block)
|
2018-02-16 08:33:50 -05:00
|
|
|
ranges = []
|
2021-09-30 14:11:31 -04:00
|
|
|
offset = 0
|
2016-07-10 16:17:20 -04:00
|
|
|
|
2021-09-30 14:11:31 -04:00
|
|
|
while match = regex.match(raw_line[offset..])
|
|
|
|
begin_index = match.begin(group) + offset
|
|
|
|
end_index = match.end(group) + offset
|
2016-07-10 16:17:20 -04:00
|
|
|
|
2018-02-16 08:33:50 -05:00
|
|
|
ranges << (begin_index..(end_index - 1))
|
2021-09-30 14:11:31 -04:00
|
|
|
|
|
|
|
offset = end_index
|
2018-02-16 08:33:50 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
super(ranges, &block)
|
2016-07-10 16:17:20 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|