Sha256: 123f37db078e3b91eadad85c988fb2b12ba5e5f6e6a929525a046f36a25b76d9

Contents?: true

Size: 1.19 KB

Versions: 64

Compression:

Stored size: 1.19 KB

Contents

# typed: strict
# frozen_string_literal: true

module RubyIndexer
  class IndexablePath
    extend T::Sig

    sig { returns(T.nilable(String)) }
    attr_reader :require_path

    sig { returns(String) }
    attr_reader :full_path

    # An IndexablePath is instantiated with a load_path_entry and a full_path. The load_path_entry is where the file can
    # be found in the $LOAD_PATH, which we use to determine the require_path. The load_path_entry may be `nil` if the
    # indexer is configured to go through files that do not belong in the $LOAD_PATH. For example,
    # `sorbet/tapioca/require.rb` ends up being a part of the paths to be indexed because it's a Ruby file inside the
    # project, but the `sorbet` folder is not a part of the $LOAD_PATH. That means that both its load_path_entry and
    # require_path will be `nil`, since it cannot be required by the project
    sig { params(load_path_entry: T.nilable(String), full_path: String).void }
    def initialize(load_path_entry, full_path)
      @full_path = full_path
      @require_path = T.let(
        load_path_entry ? full_path.delete_prefix("#{load_path_entry}/").delete_suffix(".rb") : nil,
        T.nilable(String),
      )
    end
  end
end

Version data entries

64 entries across 64 versions & 2 rubygems

Version Path
ruby-lsp-0.22.1 lib/ruby_indexer/lib/ruby_indexer/indexable_path.rb
ruby-lsp-0.22.0 lib/ruby_indexer/lib/ruby_indexer/indexable_path.rb
ruby-lsp-0.21.3 lib/ruby_indexer/lib/ruby_indexer/indexable_path.rb
ruby-lsp-0.21.2 lib/ruby_indexer/lib/ruby_indexer/indexable_path.rb
ruby-lsp-0.21.1 lib/ruby_indexer/lib/ruby_indexer/indexable_path.rb
ruby-lsp-0.21.0 lib/ruby_indexer/lib/ruby_indexer/indexable_path.rb
ruby-lsp-0.20.1 lib/ruby_indexer/lib/ruby_indexer/indexable_path.rb
ruby-lsp-0.20.0 lib/ruby_indexer/lib/ruby_indexer/indexable_path.rb
ruby-lsp-0.19.1 lib/ruby_indexer/lib/ruby_indexer/indexable_path.rb
ruby-lsp-0.19.0 lib/ruby_indexer/lib/ruby_indexer/indexable_path.rb
ruby-lsp-0.18.4 lib/ruby_indexer/lib/ruby_indexer/indexable_path.rb
ruby-lsp-0.18.3 lib/ruby_indexer/lib/ruby_indexer/indexable_path.rb
ruby-lsp-0.18.2 lib/ruby_indexer/lib/ruby_indexer/indexable_path.rb
ruby-lsp-0.18.1 lib/ruby_indexer/lib/ruby_indexer/indexable_path.rb
ruby-lsp-0.18.0 lib/ruby_indexer/lib/ruby_indexer/indexable_path.rb
ruby-lsp-0.17.17 lib/ruby_indexer/lib/ruby_indexer/indexable_path.rb
ruby-lsp-0.17.16 lib/ruby_indexer/lib/ruby_indexer/indexable_path.rb
ruby-lsp-0.17.15 lib/ruby_indexer/lib/ruby_indexer/indexable_path.rb
ruby-lsp-0.17.14 lib/ruby_indexer/lib/ruby_indexer/indexable_path.rb
ruby-lsp-0.17.13 lib/ruby_indexer/lib/ruby_indexer/indexable_path.rb