File tree Expand file tree Collapse file tree
prism/templates/lib/prism Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -27,6 +27,11 @@ def encoding
2727 source . encoding
2828 end
2929
30+ # Returns the lines of the source code as an array of strings.
31+ def lines
32+ source . lines
33+ end
34+
3035 # Perform a byteslice on the source code using the given byte offset and
3136 # byte length.
3237 def slice ( byte_offset , length )
@@ -177,6 +182,11 @@ def inspect
177182 "#<Prism::Location @start_offset=#{ @start_offset } @length=#{ @length } start_line=#{ start_line } >"
178183 end
179184
185+ # Returns all of the lines of the source code associated with this location.
186+ def source_lines
187+ source . lines
188+ end
189+
180190 # The source code that this location represents.
181191 def slice
182192 source . slice ( start_offset , length )
Original file line number Diff line number Diff line change @@ -40,6 +40,15 @@ module Prism
4040 end
4141 end
4242
43+ # Returns all of the lines of the source code associated with this node.
44+ def source_lines
45+ location.source_lines
46+ end
47+
48+ # An alias for source_lines, used to mimic the API from
49+ # RubyVM::AbstractSyntaxTree to make it easier to migrate.
50+ alias script_lines source_lines
51+
4352 # Slice the location of the node from the source.
4453 def slice
4554 location.slice
You can’t perform that action at this time.
0 commit comments