Sha256: 1928492918a0a0552ca89a010c6e68dcf5a22413753a38b41d95539b1cc49819

Contents?: true

Size: 1.52 KB

Versions: 4

Compression:

Stored size: 1.52 KB

Contents

module Yoda
  module Typing
    module Contexts
      module ContextDerivation
        # @abstract
        # @return [Model::Environment]
        def environment
          fail NotImplementedError
        end

        # @abstract
        # @return [Types::Type]
        def receiver
          fail NotImplementedError
        end

        # @abstract
        # @return [Types::Type]
        def constant_ref
          fail NotImplementedError
        end

        # @param class_type [Types::Type]
        def derive_class_context(class_type:)
          NamespaceContext.new(
            parent: self,
            environment: environment,
            receiver: class_type,
            constant_ref: class_type,
          )
        end

        # @param receiver_type [Types::Type]
        # @param binds         [Hash{Symbol => Types::Type}, nil]
        def derive_method_context(receiver_type:, binds:)
          MethodContext.new(
            parent: self,
            environment: environment,
            receiver: receiver_type,
            constant_ref: constant_ref,
            binds: binds,
          )
        end

        # @param receiver_type [Types::Type]
        # @param binds         [Hash{Symbol => Types::Type}, nil]
        def derive_block_context(binds:, receiver_type: nil)
          BlockContext.new(
            parent: self,
            environment: environment,
            receiver: receiver_type || receiver,
            constant_ref: constant_ref,
            binds: binds,
          )
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
yoda-language-server-0.10.1 lib/yoda/typing/contexts/context_derivation.rb
yoda-language-server-0.10.0 lib/yoda/typing/contexts/context_derivation.rb
yoda-language-server-0.9.0 lib/yoda/typing/contexts/context_derivation.rb
yoda-language-server-0.8.0 lib/yoda/typing/contexts/context_derivation.rb