Class: Solargraph::Parser::ParserGem::NodeProcessors::OpasgnNode
Instance Attribute Summary
#locals, #node, #pins, #region
Instance Method Summary
collapse
#initialize
Instance Method Details
#process ⇒ void
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/solargraph/parser/parser_gem/node_processors/opasgn_node.rb', line 11
def process
target = node.children[0]
operator = node.children[1]
argument = node.children[2]
if target.type == :send
process_send_target(target, operator, argument)
elsif target.type.to_s.end_with?('vasgn')
process_vasgn_target(target, operator, argument)
else
Solargraph.assert_or_log(:opasgn_unknown_target,
"Unexpected op_asgn target type: #{target.type}")
end
end
|
#process_send_target(call, operator, argument) ⇒ void
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/solargraph/parser/parser_gem/node_processors/opasgn_node.rb', line 32
def process_send_target call, operator, argument
callee = call.children[0]
call_method = call.children[1]
asgn_method = :"#{call_method}="
new_send = node.updated(:send,
[callee,
asgn_method,
node.updated(:send, [call, operator, argument])])
NodeProcessor.process(new_send, region, pins, locals)
end
|
#process_vasgn_target(asgn, operator, argument) ⇒ void
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
|
# File 'lib/solargraph/parser/parser_gem/node_processors/opasgn_node.rb', line 68
def process_vasgn_target asgn, operator, argument
variable_name = asgn.children[0]
variable_reference_type = asgn.type.to_s.sub(/vasgn$/, 'var').to_sym
target_reference = node.updated(variable_reference_type, asgn.children)
send_children = [
target_reference,
operator,
argument
]
send_node = node.updated(:send, send_children)
new_asgn = node.updated(asgn.type, [variable_name, send_node])
NodeProcessor.process(new_asgn, region, pins, locals)
end
|