Class: GraphQL::Upgrader::Member::FieldFinder
- Inherits:
 - 
      Parser::AST::Processor
      
        
- Object
 - Parser::AST::Processor
 - GraphQL::Upgrader::Member::FieldFinder
 
 
- Defined in:
 - lib/graphql/upgrader/member.rb
 
Constant Summary
- DEFINITION_METHODS =
        
These methods are definition DSLs which may accept a block, each of these definitions is passed for transformation in its own right.
fieldandconnectiontake priority. In fact, they upgrade their own arguments, so those upgrades turn out to be no-ops. [:field, :connection, :input_field, :return_field, :argument]
Instance Attribute Summary collapse
- 
  
    
      #locations  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute locations.
 
Instance Method Summary collapse
- 
  
    
      #add_location(send_node:, source_node:)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
 - 
  
    
      #initialize  ⇒ FieldFinder 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of FieldFinder.
 - 
  
    
      #on_block(node)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
 - 
  
    
      #on_send(node)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
 
Constructor Details
#initialize ⇒ FieldFinder
Returns a new instance of FieldFinder
      863 864 865 866 867  | 
    
      # 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  | 
  
Instance Attribute Details
#locations ⇒ Object (readonly)
Returns the value of attribute locations
      861 862 863  | 
    
      # File 'lib/graphql/upgrader/member.rb', line 861 def locations @locations end  | 
  
Instance Method Details
#add_location(send_node:, source_node:) ⇒ Object
      871 872 873 874 875 876 877 878 879 880 881 882 883 884  | 
    
      # 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) ⇒ Object
      886 887 888 889 890  | 
    
      # 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) ⇒ Object
      892 893 894 895  | 
    
      # File 'lib/graphql/upgrader/member.rb', line 892 def on_send(node) add_location(send_node: node, source_node: node) super(node) end  |