Sha256: 161d516673c4f5af50e102ea597447a3a968acd5f7996909f81cfa797e409d89

Contents?: true

Size: 994 Bytes

Versions: 17

Compression:

Stored size: 994 Bytes

Contents

# typed: strict
# frozen_string_literal: true

module RubyLsp
  class RBSDocument < Document
    extend T::Sig
    extend T::Generic

    ParseResultType = type_member { { fixed: T::Array[RBS::AST::Declarations::Base] } }

    sig { params(source: String, version: Integer, uri: URI::Generic, encoding: Encoding).void }
    def initialize(source:, version:, uri:, encoding: Encoding::UTF_8)
      @syntax_error = T.let(false, T::Boolean)
      super
    end

    sig { override.returns(T::Boolean) }
    def parse!
      return false unless @needs_parsing

      @needs_parsing = false

      _, _, declarations = RBS::Parser.parse_signature(@source)
      @syntax_error = false
      @parse_result = declarations
      true
    rescue RBS::ParsingError
      @syntax_error = true
      true
    end

    sig { override.returns(T::Boolean) }
    def syntax_error?
      @syntax_error
    end

    sig { override.returns(LanguageId) }
    def language_id
      LanguageId::RBS
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
ruby-lsp-0.23.1 lib/ruby_lsp/rbs_document.rb
ruby-lsp-0.23.0 lib/ruby_lsp/rbs_document.rb
ruby-lsp-0.22.1 lib/ruby_lsp/rbs_document.rb
ruby-lsp-0.22.0 lib/ruby_lsp/rbs_document.rb
ruby-lsp-0.21.3 lib/ruby_lsp/rbs_document.rb
ruby-lsp-0.21.2 lib/ruby_lsp/rbs_document.rb
ruby-lsp-0.21.1 lib/ruby_lsp/rbs_document.rb
ruby-lsp-0.21.0 lib/ruby_lsp/rbs_document.rb
ruby-lsp-0.20.1 lib/ruby_lsp/rbs_document.rb
ruby-lsp-0.20.0 lib/ruby_lsp/rbs_document.rb
ruby-lsp-0.19.1 lib/ruby_lsp/rbs_document.rb
ruby-lsp-0.19.0 lib/ruby_lsp/rbs_document.rb
ruby-lsp-0.18.4 lib/ruby_lsp/rbs_document.rb
ruby-lsp-0.18.3 lib/ruby_lsp/rbs_document.rb
ruby-lsp-0.18.2 lib/ruby_lsp/rbs_document.rb
ruby-lsp-0.18.1 lib/ruby_lsp/rbs_document.rb
ruby-lsp-0.18.0 lib/ruby_lsp/rbs_document.rb