Sha256: d1679855a9e9d9071d900af0ea223f448567a9dc4cdc4b6cd0c02c35a3b19e01
Contents?: true
Size: 1.35 KB
Versions: 12
Compression:
Stored size: 1.35 KB
Contents
module Yoda module Parsing class Range attr_reader :begin_location, :end_location # @param begin_location [Integer] # @param end_location [Integer] def initialize(begin_location, end_location) @begin_location = begin_location @end_location = end_location end # @param ast_location [Parser::Source::Map, Parser::Source::Range] # @return [Location, nil] def self.of_ast_location(ast_location) return nil unless Location.valid_location?(ast_location) new( Location.new(row: ast_location.line, column: ast_location.column), Location.new(row: ast_location.last_line, column: ast_location.last_column), ) end # @return [{Symbol => { Symbol => Integer } }] def to_language_server_protocol_range { start: begin_location.to_language_server_protocol_range, end: end_location.to_language_server_protocol_range } end # @param row [Integer] # @param column [Integer] # @return [Range] def move(row:, column:) self.class.new(begin_location.move(row: row, column: column), end_location.move(row: row, column: column)) end # @param location [Location] # @return [true, false] def include?(location) begin_location <= location && location <= end_location end end end end
Version data entries
12 entries across 12 versions & 1 rubygems