Sha256: a20dcf161617ce353fcdc509c2299659d410fe79a27fbdcab1c1357d56a40531
Contents?: true
Size: 1.28 KB
Versions: 11
Compression:
Stored size: 1.28 KB
Contents
module Steep module AST module Node class TypeAssertion attr_reader :location def initialize(location) @location = location end def source location.source end def line location.start_line end def type(context, factory, type_vars) if ty = RBS::Parser.parse_type(type_location.buffer, range: type_location.range, variables: type_vars) ty = factory.type(ty) factory.absolute_type(ty, context: context) else nil end rescue ::RBS::ParsingError => exn exn end def type?(context, factory, type_vars) case type = type(context, factory, type_vars) when RBS::ParsingError nil else type end end def type_str @type_str ||= source.delete_prefix(":").lstrip end def type_location offset = source.size - type_str.size RBS::Location.new(location.buffer, location.start_pos + offset, location.end_pos) end def self.parse(location) if location.source =~/\A:\s*(.+)/ TypeAssertion.new(location) end end end end end end
Version data entries
11 entries across 11 versions & 1 rubygems