Sha256: 5c32ded2ebbe82d3b65f88a407d615bfa6a829b41a137923c26e78f508224cd7

Contents?: true

Size: 1.54 KB

Versions: 4

Compression:

Stored size: 1.54 KB

Contents

require 'parslet'
require 'yoda/model/yard_type_parser'

module Yoda
  module Model
    # Each type expression represents type annotations.
    # Unlike type for symbolic execution, each type expression has {LexicalScope}
    # and the corresponding constants are not determined yet.
    module TypeExpressions
      require 'yoda/model/type_expressions/base'
      require 'yoda/model/type_expressions/any_type'
      require 'yoda/model/type_expressions/value_type'
      require 'yoda/model/type_expressions/instance_type'
      require 'yoda/model/type_expressions/function_type'
      require 'yoda/model/type_expressions/generator'
      require 'yoda/model/type_expressions/duck_type'
      require 'yoda/model/type_expressions/module_type'
      require 'yoda/model/type_expressions/sequence_type'
      require 'yoda/model/type_expressions/self_type'
      require 'yoda/model/type_expressions/generic_type'
      require 'yoda/model/type_expressions/union_type'
      require 'yoda/model/type_expressions/unknown_type'
      require 'yoda/model/type_expressions/void_type'

      # @param string [String]
      # @return [TypeExpressions::Base]
      def self.parse(string)
        Generator.new.apply(YardTypeParser.new.parse(string))
      rescue Parslet::ParseFailed => failure
        TypeExpressions::UnknownType.new(string)
      end

      # @param strings [Array<String>]
      # @return [TypeExpressions::Base]
      def self.parse_type_strings(strings)
        TypeExpressions::UnionType.new(strings.map { |string| parse(string) })
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
yoda-language-server-0.10.1 lib/yoda/model/type_expressions.rb
yoda-language-server-0.10.0 lib/yoda/model/type_expressions.rb
yoda-language-server-0.9.0 lib/yoda/model/type_expressions.rb
yoda-language-server-0.8.0 lib/yoda/model/type_expressions.rb