Sha256: f596fe090ff41d927ed02aa2a60ad4c9087ebaccf4c3d68d60d8fe6bc1aa8627

Contents?: true

Size: 1.01 KB

Versions: 5

Compression:

Stored size: 1.01 KB

Contents

# typed: strict
# frozen_string_literal: true

module Spoom
  module Deadcode
    class Indexer < Visitor
      extend T::Sig

      sig { returns(String) }
      attr_reader :path

      sig { returns(Index) }
      attr_reader :index

      sig { params(path: String, index: Index, plugins: T::Array[Plugins::Base]).void }
      def initialize(path, index, plugins: [])
        super()

        @path = path
        @index = index
        @plugins = plugins
      end

      # Visit

      sig { override.params(node: Prism::CallNode).void }
      def visit_call_node(node)
        visit(node.receiver)

        send = Send.new(
          node: node,
          name: node.name.to_s,
          recv: node.receiver,
          args: node.arguments&.arguments || [],
          block: node.block,
          location: Location.from_prism(@path, node.location),
        )

        @plugins.each do |plugin|
          plugin.on_send(send)
        end

        visit(node.arguments)
        visit(send.block)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
spoom-1.5.0 lib/spoom/deadcode/indexer.rb
spoom-1.4.2 lib/spoom/deadcode/indexer.rb
spoom-1.4.1 lib/spoom/deadcode/indexer.rb
spoom-1.4.0 lib/spoom/deadcode/indexer.rb
spoom-1.3.3 lib/spoom/deadcode/indexer.rb