Class: Steep::Diagnostic::Signature::SyntaxError

Inherits:
Base
  • Object
show all
Defined in:
lib/steep/diagnostic/signature.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#location

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#detail_lines, #diagnostic_code, #path

Methods included from Helper

#error_name, #full_message

Constructor Details

#initialize(exception, location:) ⇒ SyntaxError

Returns a new instance of SyntaxError.



35
36
37
38
# File 'lib/steep/diagnostic/signature.rb', line 35

def initialize(exception, location:)
  super(location: location)
  @exception = exception
end

Instance Attribute Details

#exceptionObject (readonly)

Returns the value of attribute exception.



33
34
35
# File 'lib/steep/diagnostic/signature.rb', line 33

def exception
  @exception
end

Class Method Details

.parser_syntax_error_message(exception) ⇒ Object



40
41
42
43
44
45
46
47
# File 'lib/steep/diagnostic/signature.rb', line 40

def self.parser_syntax_error_message(exception)
  string = exception.location.source.to_s
  unless string.empty?
    string = " (#{string})"
  end

  "Syntax error caused by token `#{exception.token_type}`#{string}"
end

Instance Method Details

#header_lineObject



49
50
51
# File 'lib/steep/diagnostic/signature.rb', line 49

def header_line
  exception.message
end