summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBenoit Daloze <[email protected]>2024-01-24 21:12:31 +0100
committergit <[email protected]>2024-01-26 21:34:34 +0000
commitde135bc247408712a0f630010778af0b405bae1f ()
tree185a573d5dcc1a16df3fd60e7978480dbe7d5dcc /lib
parentbcafd28a3e2ec6c35d80c55a5d11c2f8aab6fc8b (diff)
[ruby/prism] Add level to warnings and errors to categorize them
* Fixes https://.com/ruby/prism/issues/2082 https://.com/ruby/prism/commit/7a74576357
-rw-r--r--lib/prism/parse_result.rb18
1 files changed, 13 insertions, 5 deletions
@@ -312,10 +312,14 @@ module Prism
# A Location object representing the location of this error in the source.
attr_reader :location
# Create a new error object with the given message and location.
- def initialize(message, location)
@message = message
@location = location
end
# Implement the hash pattern matching interface for ParseError.
@@ -325,7 +329,7 @@ module Prism
# Returns a string representation of this error.
def inspect
- "#<Prism::ParseError @message=#{@message.inspect} @location=#{@location.inspect}>"
end
end
@@ -337,20 +341,24 @@ module Prism
# A Location object representing the location of this warning in the source.
attr_reader :location
# Create a new warning object with the given message and location.
- def initialize(message, location)
@message = message
@location = location
end
# Implement the hash pattern matching interface for ParseWarning.
def deconstruct_keys(keys)
- { message: message, location: location }
end
# Returns a string representation of this warning.
def inspect
- "#<Prism::ParseWarning @message=#{@message.inspect} @location=#{@location.inspect}>"
end
end