class TypeProf::Diagnostic

Constants

SEVERITY
TAG

Attributes

msg[R]
severity[R]

Public Class Methods

new(node, meth, msg) click to toggle source
# File typeprof-0.30.1/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

Public Instance Methods

code_range() click to toggle source
# File typeprof-0.30.1/lib/typeprof/diagnostic.rb, line 17
def code_range
  @node.send(@meth)
end
reuse(new_node) click to toggle source
# File typeprof-0.30.1/lib/typeprof/diagnostic.rb, line 11
def reuse(new_node)
  @node = new_node
end
to_lsp() click to toggle source
# File typeprof-0.30.1/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