Skip to content

Commit

Permalink
Apply review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
lfittl committed Jan 27, 2024
1 parent 7b7bad9 commit abc073e
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions lib/pg_query/treewalker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,13 @@ def treewalker!(tree) # rubocop:disable Metrics/CyclomaticComplexity
node = field_descriptor.get(parent_node)
next if node.nil?
yield(node) if node.is_a?(Google::Protobuf::MessageExts) || node.is_a?(Google::Protobuf::RepeatedField)

nodes << node unless node.nil?
nodes << node
end
when Google::Protobuf::RepeatedField
parent_node.each do |node|
next if node.nil?
yield(node) if node.is_a?(Google::Protobuf::MessageExts) || node.is_a?(Google::Protobuf::RepeatedField)

nodes << node unless node.nil?
nodes << node
end
end

Expand All @@ -65,16 +63,14 @@ def treewalker_with_location!(tree) # rubocop:disable Metrics/CyclomaticComplexi
next if node.nil?
location = parent_location + [parent_field.to_sym]
yield(parent_node, parent_field.to_sym, node, location) if node.is_a?(Google::Protobuf::MessageExts) || node.is_a?(Google::Protobuf::RepeatedField)

nodes << [node, location] unless node.nil?
nodes << [node, location]
end
when Google::Protobuf::RepeatedField
parent_node.each_with_index do |node, parent_field|
next if node.nil?
location = parent_location + [parent_field]
yield(parent_node, parent_field, node, location) if node.is_a?(Google::Protobuf::MessageExts) || node.is_a?(Google::Protobuf::RepeatedField)

nodes << [node, location] unless node.nil?
nodes << [node, location]
end
end

Expand Down

0 comments on commit abc073e

Please sign in to comment.