Module: Yoda::Typing::Tree

Defined in:
lib/yoda/typing/tree.rb,
lib/yoda/typing/tree/if.rb,
lib/yoda/typing/tree/for.rb,
lib/yoda/typing/tree/base.rb,
lib/yoda/typing/tree/case.rb,
lib/yoda/typing/tree/self.rb,
lib/yoda/typing/tree/send.rb,
lib/yoda/typing/tree/begin.rb,
lib/yoda/typing/tree/super.rb,
lib/yoda/typing/tree/yield.rb,
lib/yoda/typing/tree/ensure.rb,
lib/yoda/typing/tree/rescue.rb,
lib/yoda/typing/tree/literal.rb,
lib/yoda/typing/tree/constant.rb,
lib/yoda/typing/tree/variable.rb,
lib/yoda/typing/tree/hash_tree.rb,
lib/yoda/typing/tree/block_call.rb,
lib/yoda/typing/tree/class_tree.rb,
lib/yoda/typing/tree/local_exit.rb,
lib/yoda/typing/tree/method_def.rb,
lib/yoda/typing/tree/ask_defined.rb,
lib/yoda/typing/tree/module_tree.rb,
lib/yoda/typing/tree/rescue_clause.rb,
lib/yoda/typing/tree/send_inferable.rb,
lib/yoda/typing/tree/conditional_loop.rb,
lib/yoda/typing/tree/logical_operator.rb,
lib/yoda/typing/tree/method_inferable.rb,
lib/yoda/typing/tree/literal_inferable.rb,
lib/yoda/typing/tree/interpolation_text.rb,
lib/yoda/typing/tree/logical_assignment.rb,
lib/yoda/typing/tree/constant_assignment.rb,
lib/yoda/typing/tree/multiple_assignment.rb,
lib/yoda/typing/tree/namespace_inferable.rb,
lib/yoda/typing/tree/variable_assignment.rb,
lib/yoda/typing/tree/singleton_class_tree.rb,
lib/yoda/typing/tree/singleton_method_def.rb

Defined Under Namespace

Modules: LiteralInferable, MethodInferable, NamespaceInferable, SendInferable Classes: AskDefined, Base, Begin, BlockCall, Case, ClassTree, ConditionalLoop, Constant, ConstantAssignment, Ensure, For, HashTree, If, InterpolationText, Literal, LocalExit, LogicalAssignment, LogicalOperator, MethodDef, ModuleTree, MultipleAssignment, Rescue, RescueClause, Self, Send, SingletonClassTree, SingletonMethodDef, Super, Variable, VariableAssignment, Yield

Class Method Summary collapse

Class Method Details

.build(node, **kwargs) ⇒ Base

Parameters:

  • node (::AST::Node)

Returns:



43
44
45
# File 'lib/yoda/typing/tree.rb', line 43

def build(node, **kwargs)
  klass_for_node(node).new(node: node, **kwargs)
end

.klass_for_node(node) ⇒ class<Base>

Parameters:

  • node (::AST::Node)

Returns:



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/yoda/typing/tree.rb', line 49

def klass_for_node(node)
  case node.type
  when :lvasgn, :ivasgn, :cvasgn, :gvasgn
    VariableAssignment
  when :casgn
    ConstantAssignment
  when :masgn
    MultipleAssignment
  when :op_asgn, :or_asgn, :and_asgn
    LogicalAssignment
  when :and, :or, :not
    LogicalOperator
  when :if
    If
  when :while, :until, :while_post, :until_post
    ConditionalLoop
  when :for
    For
  when :case
    Case
  when :super, :zsuper
    Super
  when :yield
    Yield
  when :return, :break, :next
    LocalExit
  when :ensure
    Ensure
  when :rescue
    Rescue
  when :resbody
    RescueClause
  when :csend, :send
    Send
  when :block
    BlockCall
  when :const
    Constant
  when :lvar, :cvar, :ivar, :gvar
    Variable
  when :begin, :kwbegin, :block
    Begin
  when :dstr, :dsym, :xstr
    InterpolationText
  when :def
    MethodDef
  when :defs
    SingletonMethodDef
  when :hash
    HashTree
  when :self
    Self
  when :defined?
    AskDefined
  when :class
    ClassTree
  when :module
    ModuleTree
  when :sclass
    SingletonClassTree
  else
    Literal
  end
end