Class: Spoom::Deadcode::Plugins::GraphQL

Inherits:
Base
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/spoom/deadcode/plugins/graphql.rb

Instance Method Summary collapse

Methods inherited from Base

ignore_classes_inheriting_from, ignore_classes_named, ignore_constants_named, ignore_methods_named, ignore_modules_named, #internal_on_define_accessor, #internal_on_define_class, #internal_on_define_constant, #internal_on_define_method, #internal_on_define_module, #internal_on_send, #on_define_accessor, #on_define_class, #on_define_constant, #on_define_method, #on_define_module

Instance Method Details

#on_send(indexer, send) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/spoom/deadcode/plugins/graphql.rb', line 28

def on_send(indexer, send)
  return unless send.recv.nil? && send.name == "field"

  arg = send.args.first
  return unless arg.is_a?(Prism::SymbolNode)

  indexer.reference_method(arg.unescaped, send.node)

  send.each_arg_assoc do |key, value|
    key = key.slice.delete_suffix(":")
    next unless key == "resolver_method"
    next unless value

    indexer.reference_method(value.slice.delete_prefix(":"), send.node)
  end
end