Class Parser::Diagnostic
In: lib/parser/diagnostic.rb
Parent: Object

@api public

@!attribute [r] level

 @see LEVELS
 @return [Symbol] diagnostic level

@!attribute [r] reason

 @see Parser::MESSAGES
 @return [Symbol] reason for error

@!attribute [r] arguments

 @see Parser::MESSAGES
 @return [Symbol] extended arguments that describe the error

@!attribute [r] message

 @return [String] error message

@!attribute [r] location

 Main error-related source range.
 @return [Parser::Source::Range]

@!attribute [r] highlights

 Supplementary error-related source ranges.
 @return [Array<Parser::Source::Range>]

Methods

message   new   render  

Constants

LEVELS = [:note, :warning, :error, :fatal].freeze   Collection of the available diagnostic levels.

@return [Array]

Attributes

arguments  [R] 
highlights  [R] 
level  [R] 
location  [R] 
reason  [R] 

Public Class methods

@param [Symbol] level @param [Symbol] reason @param [Hash] arguments @param [Parser::Source::Range] location @param [Array<Parser::Source::Range>] highlights

Public Instance methods

@return [String] the rendered message.

Renders the diagnostic message as a clang-like diagnostic.

@example

 diagnostic.render # =>
 # [
 #   "(fragment:0):1:5: error: unexpected token $end",
 #   "foo +",
 #   "    ^"
 # ]

@return [Array<String>]

[Validate]