Sha256: f255813aeaf73f248341aeaafa457f2b08a13406ea10e7db3abbe14459b145fe

Contents?: true

Size: 944 Bytes

Versions: 1

Compression:

Stored size: 944 Bytes

Contents

# typed: strict
# frozen_string_literal: true

module YARDSorbet
  module Handlers
    # Tracks modules that invoke `mixes_in_class_methods` for use in {IncludeHandler}
    # @see https://sorbet.org/docs/abstract#interfaces-and-the-included-hook
    #   Sorbet `mixes_in_class_methods` documentation
    class MixesInClassMethodsHandler < YARD::Handlers::Ruby::Base
      extend T::Sig

      handles method_call(:mixes_in_class_methods)
      namespace_only

      @@mix_in_class_methods = T.let({}, T::Hash[String, T::Array[String]]) # rubocop:disable Style/ClassVars

      sig { params(code_obj: String).returns(T.nilable(T::Array[String])) }
      def self.mixed_in_class_methods(code_obj) = @@mix_in_class_methods[code_obj]

      sig { void }
      def process
        @@mix_in_class_methods[namespace.to_s] ||= []
        @@mix_in_class_methods.fetch(namespace.to_s) << statement.parameters(false)[0].source
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
yard-sorbet-0.9.0 lib/yard-sorbet/handlers/mixes_in_class_methods_handler.rb