File tree Expand file tree Collapse file tree 1 file changed +18
-11
lines changed
lib/synvert/core/rewriter/scope Expand file tree Collapse file tree 1 file changed +18
-11
lines changed Original file line number Diff line number Diff line change @@ -22,24 +22,31 @@ def process
22
22
current_node = @instance . current_node
23
23
return unless current_node
24
24
25
+ matching_nodes = find_matching_nodes ( current_node )
25
26
@instance . process_with_node current_node do
26
- matching_nodes = [ ]
27
- matching_nodes << current_node if current_node . match? @rules
28
- if @options [ :recursive ]
29
- current_node . recursive_children do |child_node |
30
- matching_nodes << child_node if child_node . match? @rules
31
- end
32
- else
33
- current_node . children do |child_node |
34
- matching_nodes << child_node if child_node . match? @rules
35
- end
36
- end
37
27
matching_nodes . each do |matching_node |
38
28
@instance . process_with_node matching_node do
39
29
@instance . instance_eval &@block
40
30
end
41
31
end
42
32
end
43
33
end
34
+
35
+ private
36
+
37
+ def find_matching_nodes ( current_node )
38
+ matching_nodes = [ ]
39
+ if @options [ :recursive ]
40
+ matching_nodes << current_node if current_node . match? @rules
41
+ current_node . recursive_children do |child_node |
42
+ matching_nodes << child_node if child_node . match? @rules
43
+ end
44
+ else
45
+ current_node . each do |child_node |
46
+ matching_nodes << child_node if child_node . match? @rules
47
+ end
48
+ end
49
+ matching_nodes
50
+ end
44
51
end
45
52
end
You can’t perform that action at this time.
0 commit comments