Class: Leftovers::AST::Node
- Inherits:
-
Parser::AST::Node
- Object
- Parser::AST::Node
- Leftovers::AST::Node
show all
- Defined in:
- lib/leftovers/ast/node.rb
Direct Known Subclasses
ArrayNode, BlockNode, CasgnNode, ConstNode, DefNode, DefsNode, FalseNode, HashNode, ModuleNode, NilNode, NumericNode, SendNode, StrNode, SymNode, TrueNode, VarNode, VasgnNode, DefinitionNode
Instance Method Summary
collapse
Constructor Details
#initialize(type, children = [], properties = {}) ⇒ Node
Returns a new instance of Node.
8
9
10
11
12
13
14
|
# File 'lib/leftovers/ast/node.rb', line 8
def initialize(type, children = [], properties = {})
@memo = {}
super
end
|
Instance Method Details
#arguments ⇒ Object
90
91
92
|
# File 'lib/leftovers/ast/node.rb', line 90
def arguments
nil
end
|
#as_arguments_list ⇒ Object
86
87
88
|
# File 'lib/leftovers/ast/node.rb', line 86
def as_arguments_list
@memo[:as_arguments_list] ||= [self]
end
|
#block_given? ⇒ Boolean
110
111
112
|
# File 'lib/leftovers/ast/node.rb', line 110
def block_given?
false
end
|
#first ⇒ Object
26
27
28
|
# File 'lib/leftovers/ast/node.rb', line 26
def first
children.first
end
|
#hash? ⇒ Boolean
74
75
76
|
# File 'lib/leftovers/ast/node.rb', line 74
def hash?
false
end
|
#kwargs ⇒ Object
102
103
104
|
# File 'lib/leftovers/ast/node.rb', line 102
def kwargs
nil
end
|
#name ⇒ Object
106
107
108
|
# File 'lib/leftovers/ast/node.rb', line 106
def name
nil
end
|
#parent ⇒ Object
46
47
48
|
# File 'lib/leftovers/ast/node.rb', line 46
def parent
@memo[:parent]
end
|
#parent=(value) ⇒ Object
50
51
52
|
# File 'lib/leftovers/ast/node.rb', line 50
def parent=(value)
@memo[:parent] = value
end
|
#path ⇒ Object
34
35
36
|
# File 'lib/leftovers/ast/node.rb', line 34
def path
loc.expression.source_buffer.name
end
|
#positional_arguments ⇒ Object
94
95
96
|
# File 'lib/leftovers/ast/node.rb', line 94
def positional_arguments
nil
end
|
#privacy ⇒ Object
42
43
44
|
# File 'lib/leftovers/ast/node.rb', line 42
def privacy
@memo[:privacy] || :public
end
|
#privacy=(value) ⇒ Object
38
39
40
|
# File 'lib/leftovers/ast/node.rb', line 38
def privacy=(value)
@memo[:privacy] = value
end
|
#proc? ⇒ Boolean
78
79
80
|
# File 'lib/leftovers/ast/node.rb', line 78
def proc?
false
end
|
#receiver ⇒ Object
98
99
100
|
# File 'lib/leftovers/ast/node.rb', line 98
def receiver
nil
end
|
#scalar? ⇒ Boolean
58
59
60
|
# File 'lib/leftovers/ast/node.rb', line 58
def scalar?
false
end
|
#second ⇒ Object
30
31
32
|
# File 'lib/leftovers/ast/node.rb', line 30
def second
children[1]
end
|
#sym? ⇒ Boolean
82
83
84
|
# File 'lib/leftovers/ast/node.rb', line 82
def sym?
false
end
|
#to_literal_s ⇒ Object
70
71
72
|
# File 'lib/leftovers/ast/node.rb', line 70
def to_literal_s
nil
end
|
#to_s ⇒ Object
62
63
64
|
# File 'lib/leftovers/ast/node.rb', line 62
def to_s
''
end
|
#to_scalar_value ⇒ Object
54
55
56
|
# File 'lib/leftovers/ast/node.rb', line 54
def to_scalar_value
nil
end
|
#to_sym ⇒ Object
66
67
68
|
# File 'lib/leftovers/ast/node.rb', line 66
def to_sym
:''
end
|
#updated(type = nil, children = nil, properties = nil) ⇒ Object
This is called by ::Parser::AST internals
17
18
19
20
21
22
23
24
|
# File 'lib/leftovers/ast/node.rb', line 17
def updated(type = nil, children = nil, properties = nil) maybe_copy = super
class_for_type = Builder.node_class(maybe_copy.type)
return maybe_copy if maybe_copy.instance_of?(class_for_type)
class_for_type.new(maybe_copy.type, maybe_copy.children, location: maybe_copy.loc)
end
|