diff options
author | Kevin Newton <[email protected]> | 2024-02-18 15:14:46 -0500 |
---|---|---|
committer | git <[email protected]> | 2024-02-18 20:57:13 +0000 |
commit | 792804e32f7aaa1008acd01068df3c0b85cd8ffe () | |
tree | a3a60adedc5f09c4875e630e7169fa2ec25b9dc3 /lib/prism/parse_result.rb | |
parent | 07c774e85cf0a3352c045ec3ae83db1215962997 (diff) |
[ruby/prism] Split up comments between leading and trailing
Also make them lazy to allocate the array, and also expose ParseResult#encoding. https://.com/ruby/prism/commit/08ec7683ae
-rw-r--r-- | lib/prism/parse_result.rb | 54 |
1 files changed, 50 insertions, 4 deletions
@@ -21,6 +21,12 @@ module Prism @offsets = offsets # set after parsing is done end # Perform a byteslice on the source code using the given byte offset and # byte length. def slice(byte_offset, length) @@ -108,16 +114,46 @@ module Prism # The length of this location in bytes. attr_reader :length - # The list of comments attached to this location - attr_reader :comments - # Create a new location object with the given source, start byte offset, and # byte length. def initialize(source, start_offset, length) @source = source @start_offset = start_offset @length = length - @comments = [] end # Create a new location object with the given options. @@ -268,6 +304,11 @@ module Prism def deconstruct_keys(keys) { location: location } end end # InlineComment objects are the most common. They correspond to comments in @@ -437,6 +478,11 @@ module Prism { value: value, comments: comments, magic_comments: magic_comments, data_loc: data_loc, errors: errors, warnings: warnings } end # Returns true if there were no errors during parsing and false if there # were. def success? |