Sha256: e12caf9d949cab4ed5d12ff0d8425950b17429fc14c86261762a5df38d8e8372

Contents?: true

Size: 1.74 KB

Versions: 1

Compression:

Stored size: 1.74 KB

Contents

module Steep
  class Project
    class Target
      attr_reader :name
      attr_reader :options

      attr_reader :source_pattern
      attr_reader :signature_pattern
      attr_reader :code_diagnostics_config

      def initialize(name:, options:, source_pattern:, signature_pattern:, code_diagnostics_config:)
        @name = name
        @options = options
        @source_pattern = source_pattern
        @signature_pattern = signature_pattern
        @code_diagnostics_config = code_diagnostics_config

        @source_files = {}
        @signature_files = {}
      end

      def possible_source_file?(path)
        source_pattern =~ path
      end

      def possible_signature_file?(path)
        signature_pattern =~ path
      end

      def new_env_loader(project:)
        Target.construct_env_loader(options: options, project: project)
      end

      def self.construct_env_loader(options:, project:)
        repo = RBS::Repository.new(no_stdlib: options.paths.customized_stdlib?)

        if options.paths.stdlib_root
          repo.add(project.absolute_path(options.paths.stdlib_root))
        end

        options.paths.repo_paths.each do |path|
          repo.add(project.absolute_path(path))
        end

        core_root_path =
          if options.paths.customized_core?
            if options.paths.core_root
              project.absolute_path(options.paths.core_root)
            end
          else
            RBS::EnvironmentLoader::DEFAULT_CORE_ROOT
          end

        loader = RBS::EnvironmentLoader.new(core_root: core_root_path, repository: repo)

        options.libraries.each do |lib|
          name, version = lib.split(/:/, 2)
          loader.add(library: name, version: version)
        end

        loader
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
steep-0.46.0 lib/steep/project/target.rb