Sha256: 80a872ce14cc8de02aa3c53b77b2b89971583bc283104df95e9127ec1763eaac

Contents?: true

Size: 875 Bytes

Versions: 2

Compression:

Stored size: 875 Bytes

Contents

# typed: strict
# frozen_string_literal: true

module RubyLsp
  # Listener is an abstract class to be used by requests for listening to events emitted when visiting an AST using the
  # Prism::Dispatcher.
  class Listener
    extend T::Sig
    extend T::Helpers
    extend T::Generic
    include Requests::Support::Common

    ResponseType = type_member

    abstract!

    sig { params(dispatcher: Prism::Dispatcher).void }
    def initialize(dispatcher)
      super()
      @dispatcher = dispatcher
    end

    sig { returns(ResponseType) }
    def response
      _response
    end

    # Override this method with an attr_reader that returns the response of your listener. The listener should
    # accumulate results in a @response variable and then provide the reader so that it is accessible
    sig { abstract.returns(ResponseType) }
    def _response; end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ruby-lsp-0.13.4 lib/ruby_lsp/listener.rb
ruby-lsp-0.13.3 lib/ruby_lsp/listener.rb