Class: Yoda::Typing::NodeInfo

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/yoda/typing/node_info.rb

Overview

Facade for information of the specified node traced on inference

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node:, tracer:) ⇒ NodeInfo

Returns a new instance of NodeInfo.

Parameters:



19
20
21
22
# File 'lib/yoda/typing/node_info.rb', line 19

def initialize(node:, tracer:)
  @node = node
  @tracer = tracer
end

Instance Attribute Details

#nodeAST::Node (readonly)

Returns:



10
11
12
# File 'lib/yoda/typing/node_info.rb', line 10

def node
  @node
end

#tracerInferencer::Tracer (readonly)

Returns:



13
14
15
# File 'lib/yoda/typing/node_info.rb', line 13

def tracer
  @tracer
end

Instance Method Details

#constantsArray<Store::Objects::Base>

Returns:



40
41
42
# File 'lib/yoda/typing/node_info.rb', line 40

def constants
  tracer.constants(node)
end

#kindSymbol

Returns:

  • (Symbol)


25
26
27
# File 'lib/yoda/typing/node_info.rb', line 25

def kind
  tracer.kind(node) || node.type
end

#lexical_scope_typesArray<Store::Objects::NamespaceObject>



65
66
67
# File 'lib/yoda/typing/node_info.rb', line 65

def lexical_scope_types
  context&.lexical_scope_types || []
end

#method_candidatesArray<FunctionSignatures::Base>

Returns:

  • (Array<FunctionSignatures::Base>)


35
36
37
# File 'lib/yoda/typing/node_info.rb', line 35

def method_candidates
  tracer.method_candidates(node)
end

#objectsArray<Store::Objects::Base>

Returns:



55
56
57
# File 'lib/yoda/typing/node_info.rb', line 55

def objects
  tracer.objects(node)
end

#receiver_typeTypes::Type

Returns:



30
31
32
# File 'lib/yoda/typing/node_info.rb', line 30

def receiver_type
  tracer.receiver_type(node)
end

#require_pathsArray<String>

Returns:

  • (Array<String>)


45
46
47
# File 'lib/yoda/typing/node_info.rb', line 45

def require_paths
  tracer.require_paths(node)
end

#resolve_constant(path_expr) ⇒ Types::Type?

Parameters:

  • path_expr (String)

Returns:



71
72
73
# File 'lib/yoda/typing/node_info.rb', line 71

def resolve_constant(path_expr)
  context&.constant_resolver&.resolve_path(path_expr.to_s)
end

#scope_objectsArray<Store::Objects::Base>

Returns:



60
61
62
# File 'lib/yoda/typing/node_info.rb', line 60

def scope_objects
  tracer.objects(node)
end

#typeTypes::Type

Returns:



50
51
52
# File 'lib/yoda/typing/node_info.rb', line 50

def type
  tracer.type(node)
end