instance method
Prism::Translation::Parser::Compiler#srange_semicolon
srange_semicolon(start_offset, end_offset)
lib/prism/translation/parser/compiler.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/lib/prism/translation/parser/compiler.rb, line 2021
def srange_semicolon(start_offset, end_offset)
if (match = source_buffer.source.byteslice(start_offset...end_offset)[/\A\s*;/])
final_offset = start_offset + match.bytesize
[";", Range.new(source_buffer, offset_cache[final_offset - 1], offset_cache[final_offset])]
end
end
Constructs a new source range by finding a semicolon between the given start offset and end offset. If the semicolon is not found, it returns nil. Importantly it does not search past newlines or comments.
Note that end_offset is allowed to be nil, in which case this will search until the end of the string.