Skip to content

Commit 6841fa0

Browse files
committed
use NodeMutation.adapter to get node line
1 parent 76ff967 commit 6841fa0

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

lib/rails/redirect_with_flash.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@
3838
remover_action = nil
3939
flash_type = nil
4040
with_node node_type: 'send', receiver: 'flash', arguments: { size: 2, last: { node_type: :str } } do
41-
line = node.line
41+
line = NodeMutation.adapter.get_start_loc(node).line
4242
flash_type = node.arguments.first.to_source
4343
msg = node.arguments.last.to_source
4444
remover_action = NodeMutation::RemoveAction.new(node)
4545
end
4646
with_node node_type: 'send', receiver: nil, message: :redirect_to do
47-
if line.present? && node.line == line + 1
47+
if line.present? && NodeMutation.adapter.get_start_loc(node).line == line + 1
4848
add_action(remover_action)
4949
if [':notice', ':alert'].include?(flash_type)
5050
replace_with "{{message}} {{arguments}}, #{flash_type[1..-1]}: #{msg}"

lib/ruby/merge_to_square_brackets.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@
7171
# enum.inject({}) { |h, e| h[e] = e; h }
7272
find_node '.block[caller=.send[message=inject]][arguments.size=2][body.size=1]' do
7373
hash_name = node.arguments.first.name.to_s
74-
block_start_line = node.line
74+
block_start_line = NodeMutation.adapter.get_start_loc(node).line
7575
find_node ".send[receiver=#{hash_name}][message IN (merge merge!)][arguments.size=1][arguments.first=.hash]" do
76-
merge_line = node.line
76+
merge_line = NodeMutation.adapter.get_start_loc(node).line
7777
splitter = block_start_line == merge_line ? '; ' : "\n"
7878
new_code = hash_node_to_square_brackets_code(node.arguments.first, splitter)
7979
replace_with "#{new_code}#{splitter}#{hash_name}"
@@ -93,9 +93,9 @@
9393
# enum.each_with_object({}) { |e, h| h[e] = e }
9494
find_node '.block[caller=.send[message=each_with_object]][arguments.size=2][body.size=1]' do
9595
hash_name = node.arguments.last.name.to_s
96-
block_start_line = node.line
96+
block_start_line = NodeMutation.adapter.get_start_loc(node).line
9797
find_node ".send[receiver=#{hash_name}][message IN (merge merge!)][arguments.size=1][arguments.first=.hash]" do
98-
merge_line = node.line
98+
merge_line = NodeMutation.adapter.get_start_loc(node).line
9999
splitter = block_start_line == merge_line ? '; ' : "\n"
100100
new_code = hash_node_to_square_brackets_code(node.arguments.first, splitter)
101101
replace_with new_code

0 commit comments

Comments
 (0)