Sha256: 14f3fc210bb2f640043cf886891bb633f3817deded2e5a97b961eaa7ff9cd9aa

Contents?: true

Size: 1.11 KB

Versions: 27

Compression:

Stored size: 1.11 KB

Contents

# typed: strict
# frozen_string_literal: true

module RubyLsp
  module Requests
    module Support
      class Annotation
        extend T::Sig
        sig do
          params(
            arity: T.any(Integer, T::Range[Integer]),
            receiver: T::Boolean,
          ).void
        end
        def initialize(arity:, receiver: false)
          @arity = arity
          @receiver = receiver
        end

        sig { returns(T.any(Integer, T::Range[Integer])) }
        attr_reader :arity

        sig { returns(T::Boolean) }
        attr_reader :receiver

        sig { params(arity: T.any(T::Range[Integer], Integer)).returns(T::Boolean) }
        def supports_arity?(arity)
          if @arity.is_a?(Integer)
            @arity == arity
          elsif @arity.is_a?(Range)
            @arity.cover?(arity)
          else
            T.absurd(@arity)
          end
        end

        sig { params(receiver: T.nilable(String)).returns(T::Boolean) }
        def supports_receiver?(receiver)
          return receiver.nil? || receiver.empty? if @receiver == false

          receiver == "T"
        end
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
ruby-lsp-0.10.1 lib/ruby_lsp/requests/support/annotation.rb
ruby-lsp-0.10.0 lib/ruby_lsp/requests/support/annotation.rb
ruby-lsp-0.9.4 lib/ruby_lsp/requests/support/annotation.rb
ruby-lsp-0.9.3 lib/ruby_lsp/requests/support/annotation.rb
ruby-lsp-0.9.2 lib/ruby_lsp/requests/support/annotation.rb
ruby-lsp-0.9.1 lib/ruby_lsp/requests/support/annotation.rb
ruby-lsp-0.9.0 lib/ruby_lsp/requests/support/annotation.rb
ruby-lsp-0.8.1 lib/ruby_lsp/requests/support/annotation.rb
ruby-lsp-0.8.0 lib/ruby_lsp/requests/support/annotation.rb
ruby-lsp-0.7.6 lib/ruby_lsp/requests/support/annotation.rb
ruby-lsp-0.7.5 lib/ruby_lsp/requests/support/annotation.rb
ruby-lsp-0.7.4 lib/ruby_lsp/requests/support/annotation.rb
ruby-lsp-0.7.3 lib/ruby_lsp/requests/support/annotation.rb
ruby-lsp-0.7.2 lib/ruby_lsp/requests/support/annotation.rb
ruby-lsp-0.7.1 lib/ruby_lsp/requests/support/annotation.rb
ruby-lsp-0.7.0 lib/ruby_lsp/requests/support/annotation.rb
ruby-lsp-0.6.2 lib/ruby_lsp/requests/support/annotation.rb
ruby-lsp-0.6.1 lib/ruby_lsp/requests/support/annotation.rb
ruby-lsp-0.6.0 lib/ruby_lsp/requests/support/annotation.rb
ruby-lsp-0.5.1 lib/ruby_lsp/requests/support/annotation.rb