class GraphQL::Upgrader::Member::FieldFinder
Constants
- DEFINITION_METHODS
These methods are definition DSLs which may accept a block, each of these definitions is passed for transformation in its own right. `field` and `connection` take priority. In fact, they upgrade their own arguments, so those upgrades turn out to be no-ops.
Attributes
locations[R]
Public Class Methods
new()
click to toggle source
# File lib/graphql/upgrader/member.rb, line 863 def initialize # Pairs of `{ { method_name => { name => [start, end] } }`, # since fields/arguments are unique by name, within their category @locations = Hash.new { |h,k| h[k] = {} } end
Public Instance Methods
add_location(send_node:,source_node:)
click to toggle source
@param send_node [node] The node which might be a `field` call, etc @param source_node [node] The node whose source defines the bounds of the definition (eg, the surrounding block)
# File lib/graphql/upgrader/member.rb, line 871 def add_location(send_node:,source_node:) receiver_node, method_name, *arg_nodes = *send_node # Implicit self and one of the recognized methods if receiver_node.nil? && DEFINITION_METHODS.include?(method_name) name = arg_nodes[0] # This field may have already been added because # we find `(block ...)` nodes _before_ we find `(send ...)` nodes. if @locations[method_name][name].nil? starting_idx = source_node.loc.expression.begin.begin_pos ending_idx = source_node.loc.expression.end.end_pos @locations[method_name][name] = [starting_idx, ending_idx] end end end
on_block(node)
click to toggle source
Calls superclass method
# File lib/graphql/upgrader/member.rb, line 886 def on_block(node) send_node, _args_node, _body_node = *node add_location(send_node: send_node, source_node: node) super(node) end
on_send(node)
click to toggle source
Calls superclass method
# File lib/graphql/upgrader/member.rb, line 892 def on_send(node) add_location(send_node: node, source_node: node) super(node) end