Sha256: e77705f55d6f9693f2f5c35272be65f9541d5e65f95d54fb70bae94be768bd76

Contents?: true

Size: 835 Bytes

Versions: 3

Compression:

Stored size: 835 Bytes

Contents

# typed: strict
# frozen_string_literal: true

module RubyLsp
  module Requests
    # :nodoc:
    class BaseRequest < YARP::Visitor
      extend T::Sig
      extend T::Helpers
      include Support::Common

      abstract!

      sig { params(document: Document).void }
      def initialize(document)
        @document = document
        super()
      end

      sig { abstract.returns(Object) }
      def run; end

      # YARP implements `visit_all` using `map` instead of `each` for users who want to use the pattern
      # `result = visitor.visit(tree)`. However, we don't use that pattern and should avoid producing a new array for
      # every single node visited
      sig { params(nodes: T::Array[T.nilable(YARP::Node)]).void }
      def visit_all(nodes)
        nodes.each { |node| visit(node) }
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ruby-lsp-0.11.2 lib/ruby_lsp/requests/base_request.rb
ruby-lsp-0.11.1 lib/ruby_lsp/requests/base_request.rb
ruby-lsp-0.11.0 lib/ruby_lsp/requests/base_request.rb