Class: Steep::Index::SourceIndex::MethodEntry

Inherits:
Object
  • Object
show all
Defined in:
lib/steep/index/source_index.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:) ⇒ MethodEntry

Returns a new instance of MethodEntry.



52
53
54
55
56
57
# File 'lib/steep/index/source_index.rb', line 52

def initialize(name:)
  @name = name

  @definitions = Set[].compare_by_identity
  @references = Set[].compare_by_identity
end

Instance Attribute Details

#definitionsObject (readonly)

Returns the value of attribute definitions.



49
50
51
# File 'lib/steep/index/source_index.rb', line 49

def definitions
  @definitions
end

#nameObject (readonly)

Returns the value of attribute name.



47
48
49
# File 'lib/steep/index/source_index.rb', line 47

def name
  @name
end

#referencesObject (readonly)

Returns the value of attribute references.



50
51
52
# File 'lib/steep/index/source_index.rb', line 50

def references
  @references
end

Instance Method Details

#add_definition(node) ⇒ Object



59
60
61
62
63
64
65
66
67
68
# File 'lib/steep/index/source_index.rb', line 59

def add_definition(node)
  case node.type
  when :def, :defs
    @definitions << node
  else
    raise "Unexpected method definition: #{node.type}"
  end

  self
end

#add_reference(node) ⇒ Object



70
71
72
73
74
75
76
77
78
79
# File 'lib/steep/index/source_index.rb', line 70

def add_reference(node)
  case node.type
  when :send, :block
    @references << node
  else
    raise "Unexpected method reference: #{node.type}"
  end

  self
end

#merge!(other) ⇒ Object



81
82
83
84
85
# File 'lib/steep/index/source_index.rb', line 81

def merge!(other)
  definitions.merge(other.definitions)
  references.merge(other.references)
  self
end