class Yoda::Commands::Infer

Attributes

filename_with_position[R]

Public Class Methods

new(filename_with_position) click to toggle source

@param filename_with_position [String] position representation with the format `path/to/file:line_num:character_num`

# File lib/yoda/commands/infer.rb, line 7
def initialize(filename_with_position)
  @filename_with_position = filename_with_position
end

Public Instance Methods

run() click to toggle source
# File lib/yoda/commands/infer.rb, line 11
def run
  project.build_cache
  puts create_signature_help(worker.current_node_signature)
end

Private Instance Methods

create_signature_help(signature) click to toggle source

@param signature [Model::NodeSignature, nil] @return [String, nil]

# File lib/yoda/commands/infer.rb, line 20
def create_signature_help(signature)
  return nil unless signature
  signature.descriptions.map(&:title).join("\n")
end
filename() click to toggle source
# File lib/yoda/commands/infer.rb, line 33
def filename
  @filename ||= filename_with_position.split(':').first
end
position() click to toggle source
# File lib/yoda/commands/infer.rb, line 37
def position
  @position ||= begin
    row, column = filename_with_position.split(':').slice(1..2)
    Parsing::Location.new(row: row.to_i, column: column.to_i)
  end
end
project() click to toggle source
# File lib/yoda/commands/infer.rb, line 29
def project
  @project ||= Store::Project.new(Dir.pwd)
end
worker() click to toggle source
# File lib/yoda/commands/infer.rb, line 25
def worker
  @worker ||= Evaluation::CurrentNodeExplain.new(project.registry, File.read(filename), position)
end