Sha256: d0a3cd8e001df3cbe458956d87b2e5803677b824401a781334943d9da0b60f67

Contents?: true

Size: 1.21 KB

Versions: 7

Compression:

Stored size: 1.21 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 ? Pathname.new(full_path).relative_path_from(load_path_entry).to_s.delete_suffix(".rb") : nil,
        T.nilable(String),
      )
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ruby-lsp-0.12.0 lib/ruby_indexer/lib/ruby_indexer/indexable_path.rb
ruby-lsp-0.11.2 lib/ruby_indexer/lib/ruby_indexer/indexable_path.rb
ruby-lsp-0.11.1 lib/ruby_indexer/lib/ruby_indexer/indexable_path.rb
ruby-lsp-0.11.0 lib/ruby_indexer/lib/ruby_indexer/indexable_path.rb
ruby-lsp-0.10.1 lib/ruby_indexer/lib/ruby_indexer/indexable_path.rb
ruby-lsp-0.10.0 lib/ruby_indexer/lib/ruby_indexer/indexable_path.rb
ruby-lsp-0.9.4 lib/ruby_indexer/lib/ruby_indexer/indexable_path.rb