diff options
| author | Kevin Newton <kddnewton@gmail.com> | 2024-03-06 13:18:55 -0500 |
|---|---|---|
| committer | Kevin Newton <kddnewton@gmail.com> | 2024-03-06 21:42:54 -0500 |
| commit | 38c2774420674fd1c6ef1f12dc641f5cfc6140aa (patch) | |
| tree | e85b5624b381f0930c6c3481dc67679ae86b0e42 /lib | |
| parent | c0cb3f60e1ee86b69c42809fb98e63a7e2158445 (diff) | |
[ruby/prism] Expose types on diagnostics
https://github.com/ruby/prism/commit/a735c2262f
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/prism/parse_result.rb | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/lib/prism/parse_result.rb b/lib/prism/parse_result.rb index c54c883eea..24ae1cb69b 100644 --- a/lib/prism/parse_result.rb +++ b/lib/prism/parse_result.rb @@ -366,6 +366,9 @@ module Prism # This represents an error that was encountered during parsing. class ParseError + # The type of error. + attr_reader :type + # The message associated with this error. attr_reader :message @@ -376,7 +379,8 @@ module Prism attr_reader :level # Create a new error object with the given message and location. - def initialize(message, location, level) + def initialize(type, message, location, level) + @type = type @message = message @location = location @level = level @@ -384,17 +388,20 @@ module Prism # Implement the hash pattern matching interface for ParseError. def deconstruct_keys(keys) - { message: message, location: location, level: level } + { type: type, message: message, location: location, level: level } end # Returns a string representation of this error. def inspect - "#<Prism::ParseError @message=#{@message.inspect} @location=#{@location.inspect} @level=#{@level.inspect}>" + "#<Prism::ParseError @type=#{@type.inspect} @message=#{@message.inspect} @location=#{@location.inspect} @level=#{@level.inspect}>" end end # This represents a warning that was encountered during parsing. class ParseWarning + # The type of warning. + attr_reader :type + # The message associated with this warning. attr_reader :message @@ -405,7 +412,8 @@ module Prism attr_reader :level # Create a new warning object with the given message and location. - def initialize(message, location, level) + def initialize(type, message, location, level) + @type = type @message = message @location = location @level = level @@ -413,12 +421,12 @@ module Prism # Implement the hash pattern matching interface for ParseWarning. def deconstruct_keys(keys) - { message: message, location: location, level: level } + { type: type, message: message, location: location, level: level } end # Returns a string representation of this warning. def inspect - "#<Prism::ParseWarning @message=#{@message.inspect} @location=#{@location.inspect} @level=#{@level.inspect}>" + "#<Prism::ParseWarning @type=#{@type.inspect} @message=#{@message.inspect} @location=#{@location.inspect} @level=#{@level.inspect}>" end end |
