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, tags: nil) ⇒ Diagnostic

[ GitHub ]

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

def initialize(node, meth, msg, tags: nil)
  @node = node
  @meth = meth
  @msg = msg
  @tags = tags
end

Instance Attribute Details

#msg (readonly)

[ GitHub ]

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

attr_reader :node, :msg, :tags

#node (readonly)

[ GitHub ]

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

attr_reader :node, :msg, :tags

#tags (readonly)

[ GitHub ]

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

attr_reader :node, :msg, :tags

Instance Method Details

#code_range

[ GitHub ]

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

def code_range
  @node.send(@meth)
end

#reuse(new_node)

[ GitHub ]

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

def reuse(new_node)
  @node = new_node
end

#to_lsp(severity: :error)

[ GitHub ]

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

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