[ruby/prism] Node#script_lines and supporting infra
https://github.com/ruby/prism/commit/cb4a8ab772
This commit is contained in:
parent
398453c3c0
commit
7c0cf71049
@ -27,6 +27,11 @@ module Prism
|
||||
source.encoding
|
||||
end
|
||||
|
||||
# Returns the lines of the source code as an array of strings.
|
||||
def lines
|
||||
source.lines
|
||||
end
|
||||
|
||||
# Perform a byteslice on the source code using the given byte offset and
|
||||
# byte length.
|
||||
def slice(byte_offset, length)
|
||||
@ -177,6 +182,11 @@ module Prism
|
||||
"#<Prism::Location @start_offset=#{@start_offset} @length=#{@length} start_line=#{start_line}>"
|
||||
end
|
||||
|
||||
# Returns all of the lines of the source code associated with this location.
|
||||
def source_lines
|
||||
source.lines
|
||||
end
|
||||
|
||||
# The source code that this location represents.
|
||||
def slice
|
||||
source.slice(start_offset, length)
|
||||
|
@ -40,6 +40,15 @@ module Prism
|
||||
end
|
||||
end
|
||||
|
||||
# Returns all of the lines of the source code associated with this node.
|
||||
def source_lines
|
||||
location.source_lines
|
||||
end
|
||||
|
||||
# An alias for source_lines, used to mimic the API from
|
||||
# RubyVM::AbstractSyntaxTree to make it easier to migrate.
|
||||
alias script_lines source_lines
|
||||
|
||||
# Slice the location of the node from the source.
|
||||
def slice
|
||||
location.slice
|
||||
|
Loading…
x
Reference in New Issue
Block a user