Sha256: c098cf9454c0365d8797d195daf8ee93895f6184ee6cbb04d3496ea19b21cf7a

Contents?: true

Size: 613 Bytes

Versions: 27

Compression:

Stored size: 613 Bytes

Contents

module Steep
  module ModuleHelper
    def module_name_from_node(node)
      case node.type
      when :const, :casgn
        namespace = namespace_from_node(node.children[0]) or return
        name = node.children[1]
        RBS::TypeName.new(name: name, namespace: namespace)
      end
    end

    def namespace_from_node(node)
      case node&.type
      when nil
        RBS::Namespace.empty
      when :cbase
        RBS::Namespace.root
      when :const
        namespace_from_node(node.children[0])&.yield_self do |parent|
          parent.append(node.children[1])
        end
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
steep-0.50.0 lib/steep/module_helper.rb
steep-0.49.1 lib/steep/module_helper.rb
steep-0.49.0 lib/steep/module_helper.rb
steep-0.48.0 lib/steep/module_helper.rb
steep-0.47.1 lib/steep/module_helper.rb
steep-0.47.0 lib/steep/module_helper.rb
steep-0.46.0 lib/steep/module_helper.rb
steep-0.45.0 lib/steep/module_helper.rb
steep-0.44.1 lib/steep/module_helper.rb
steep-0.44.0 lib/steep/module_helper.rb
steep-0.43.1 lib/steep/module_helper.rb
steep-0.43.0 lib/steep/module_helper.rb
steep-0.42.0 lib/steep/module_helper.rb
steep-0.41.0 lib/steep/module_helper.rb
steep-0.40.0 lib/steep/module_helper.rb
steep-0.39.0 lib/steep/module_helper.rb
steep-0.38.0 lib/steep/module_helper.rb
steep-0.37.0 lib/steep/module_helper.rb
steep-0.36.0 lib/steep/module_helper.rb
steep-0.35.0 lib/steep/module_helper.rb