Sha256: 125d4711ab6209438d4c221360bdd505020ddc616e2a051cc5bcb177ef97714e

Contents?: true

Size: 824 Bytes

Versions: 2

Compression:

Stored size: 824 Bytes

Contents

# typed: true
# frozen_string_literal: true

module Packwerk
  # Processes a single node in an abstract syntax tree (AST) using the provided checkers.
  class NodeProcessor
    extend T::Sig

    sig do
      params(
        reference_extractor: ReferenceExtractor,
        filename: String,
      ).void
    end
    def initialize(reference_extractor:, filename:)
      @reference_extractor = reference_extractor
      @filename = filename
    end

    sig do
      params(
        node: Parser::AST::Node,
        ancestors: T::Array[Parser::AST::Node]
      ).returns(T.nilable(Packwerk::Reference))
    end
    def call(node, ancestors)
      return unless Node.method_call?(node) || Node.constant?(node)
      @reference_extractor.reference_from_node(node, ancestors: ancestors, file_path: @filename)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
packwerk-2.0.0 lib/packwerk/node_processor.rb
packwerk-1.4.0 lib/packwerk/node_processor.rb