123456789_123456789_123456789_123456789_123456789_

Class: TypeProf::Diagnostic

Relationships & Source Files
Inherits: Object
Defined in: lib/typeprof/diagnostic.rb

Constant Summary

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(node, meth, msg) ⇒ Diagnostic

[ GitHub ]

  
# File 'lib/typeprof/diagnostic.rb', line 3

def initialize(node, meth, msg)
  @node = node
  @meth = meth
  @msg = msg
  @severity = :error # TODO: keyword argument
  @tags = nil # TODO: keyword argument
end

Instance Attribute Details

#msg (readonly)

[ GitHub ]

  
# File 'lib/typeprof/diagnostic.rb', line 15

attr_reader :msg, :severity

#severity (readonly)

[ GitHub ]

  
# File 'lib/typeprof/diagnostic.rb', line 15

attr_reader :msg, :severity

Instance Method Details

#code_range

[ GitHub ]

  
# File 'lib/typeprof/diagnostic.rb', line 17

def code_range
  @node.send(@meth)
end

#reuse(new_node)

[ GitHub ]

  
# File 'lib/typeprof/diagnostic.rb', line 11

def reuse(new_node)
  @node = new_node
end

#to_lsp

[ GitHub ]

  
# File 'lib/typeprof/diagnostic.rb', line 24

def to_lsp
  json = {
    range: code_range.to_lsp,
    source: "TypeProf",
    message: @msg,
  }
  json[:severity] = SEVERITY[@severity] if @severity
  json[:tags] = @tags.map {|tag| TAG[tag] } if @tags
  json
end