lib/prism/parse_result.rb in prism-0.19.0 vs lib/prism/parse_result.rb in prism-0.20.0

- old
+ new

@@ -310,24 +310,28 @@ attr_reader :message # A Location object representing the location of this error in the source. attr_reader :location + # The level of this error. + attr_reader :level + # Create a new error object with the given message and location. - def initialize(message, location) + def initialize(message, location, level) @message = message @location = location + @level = level end # Implement the hash pattern matching interface for ParseError. def deconstruct_keys(keys) - { message: message, location: location } + { message: message, location: location, level: level } end # Returns a string representation of this error. def inspect - "#<Prism::ParseError @message=#{@message.inspect} @location=#{@location.inspect}>" + "#<Prism::ParseError @message=#{@message.inspect} @location=#{@location.inspect} @level=#{@level.inspect}>" end end # This represents a warning that was encountered during parsing. class ParseWarning @@ -335,24 +339,28 @@ attr_reader :message # A Location object representing the location of this warning in the source. attr_reader :location + # The level of this warning. + attr_reader :level + # Create a new warning object with the given message and location. - def initialize(message, location) + def initialize(message, location, level) @message = message @location = location + @level = level end # Implement the hash pattern matching interface for ParseWarning. def deconstruct_keys(keys) - { message: message, location: location } + { message: message, location: location, level: level } end # Returns a string representation of this warning. def inspect - "#<Prism::ParseWarning @message=#{@message.inspect} @location=#{@location.inspect}>" + "#<Prism::ParseWarning @message=#{@message.inspect} @location=#{@location.inspect} @level=#{@level.inspect}>" end end # This represents the result of a call to ::parse or ::parse_file. It contains # the AST, any comments that were encounters, and any errors that were @@ -367,12 +375,12 @@ attr_reader :comments # The list of magic comments that were encountered during parsing. attr_reader :magic_comments - # An optional location that represents the location of the content after the - # __END__ marker. This content is loaded into the DATA constant when the - # file being parsed is the main file being executed. + # An optional location that represents the location of the __END__ marker + # and the rest of the content of the file. This content is loaded into the + # DATA constant when the file being parsed is the main file being executed. attr_reader :data_loc # The list of errors that were generated during parsing. attr_reader :errors