summaryrefslogtreecommitdiff
path: root/lib/prism/parse_result.rb
diff options
context:
space:
mode:
authorKevin Newton <[email protected]>2024-07-02 14:27:04 -0400
committerKevin Newton <[email protected]>2024-07-11 14:25:54 -0400
commitca48fb76fb0669ca0666a7aa129e1f5d2b7468da ()
treefce04cbe37f6976af6824f885a6032f66df7d470 /lib/prism/parse_result.rb
parent678dd769e560db9cebff41218e3413e6688aaf12 (diff)
[ruby/prism] Move location to second position for node initializers
https://.com/ruby/prism/commit/4cc0eda4ca
-rw-r--r--lib/prism/parse_result.rb13
1 files changed, 11 insertions, 2 deletions
@@ -10,7 +10,11 @@ module Prism
# specialized and more performant `ASCIISource` if no multibyte characters
# are present in the source code.
def self.for(source, start_line = 1, offsets = [])
- source.ascii_only? ? ASCIISource.new(source, start_line, offsets): new(source, start_line, offsets)
end
# The source code that this source object represents.
@@ -87,7 +91,12 @@ module Prism
# encodings, it is not captured here.
def code_units_offset(byte_offset, encoding)
byteslice = (source.byteslice(0, byte_offset) or raise).encode(encoding)
- (encoding == Encoding::UTF_16LE || encoding == Encoding::UTF_16BE) ? (byteslice.bytesize / 2) : byteslice.length
end
# Returns the column number in code units for the given encoding for the