Sha256: 5e32caa5dc203631e6fd906fe4a4f0e38f346c856e1ad7f02dd914e8ca5d0500

Contents?: true

Size: 1.79 KB

Versions: 68

Compression:

Stored size: 1.79 KB

Contents

module RBS
  # EnvironmentWalker provides topological sort of class/module definitions.
  #
  # If a method, attribute, or ancestor in a class definition have a reference to another class, it is dependency.
  #
  # ```rb
  # walker = EnvironmentWalker.new(env: env)
  #
  # walker.each_strongly_connected_component do |scc|
  #   # Yields an array of strongly connected components.
  # end
  # ```
  #
  # The `#only_ancestors!` method limits the dependency only to ancestors.
  # Only super classes and included modules are dependencies with the option.
  # This is useful to calculate the dependencies of class hierarchy.
  #
  # ```rb
  # walker = EnvironmentWalker.new(env: env).only_ancestors!
  #
  # walker.each_strongly_connected_component do |scc|
  #   # Yields an array of strongly connected components.
  # end
  # ```
  #
  class EnvironmentWalker
    class InstanceNode
      attr_reader type_name: TypeName
      def initialize: (type_name: TypeName) -> void
    end

    class SingletonNode
      attr_reader type_name: TypeName
      def initialize: (type_name: TypeName) -> void
    end

    class TypeNameNode
      attr_reader type_name: TypeName
      def initialize: (type_name: TypeName) -> void
    end

    attr_reader env: Environment
    attr_reader only_ancestors: bool
    attr_reader builder: DefinitionBuilder

    def initialize: (env: Environment) -> void

    def only_ancestors!: (?bool only) -> self

    def only_ancestors?: () -> bool

    type node = InstanceNode | SingletonNode | TypeNameNode
    include TSort[node]

    def tsort_each_node: () { (node) -> void } -> void

    def tsort_each_child: (node) { (node) -> void } -> void

    private

    def each_type_name: (Types::t) { (TypeName) -> void } -> void

    def each_type_node: (Types::t) { (node) -> void } -> void
  end
end

Version data entries

68 entries across 68 versions & 2 rubygems

Version Path
rbs-3.7.0.dev.1 sig/environment_walker.rbs
rbs-3.6.1 sig/environment_walker.rbs
rbs-3.6.0 sig/environment_walker.rbs
rbs-3.6.0.pre.3 sig/environment_walker.rbs
rbs-3.6.0.pre.2 sig/environment_walker.rbs
rbs-3.6.0.pre.1 sig/environment_walker.rbs
rbs-3.6.0.dev.1 sig/environment_walker.rbs
rbs-3.5.3 sig/environment_walker.rbs
rbs-3.5.2 sig/environment_walker.rbs
rbs-3.5.1 sig/environment_walker.rbs
rbs-3.5.1.pre.1 sig/environment_walker.rbs
rbs-3.5.0 sig/environment_walker.rbs
rbs-3.5.0.pre.2 sig/environment_walker.rbs
rbs-3.5.0.pre.1 sig/environment_walker.rbs
rbs-3.4.4 sig/environment_walker.rbs
rbs-3.4.3 sig/environment_walker.rbs
rbs-3.4.2 sig/environment_walker.rbs
getargv-0.3.3-universal-darwin vendor/bundle/ruby/3.3.0/gems/rbs-2.8.4/sig/environment_walker.rbs
rbs-3.4.1 sig/environment_walker.rbs
rbs-3.4.0 sig/environment_walker.rbs