Sha256: aa965087f1d9e995e2bb44a0e19486fbf39772c89a920340ccc38318e867bf52

Contents?: true

Size: 784 Bytes

Versions: 64

Compression:

Stored size: 784 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module AST
    module Ext
      # Extensions to Parser::AST::Range
      module Range
        # @return [Range] the range of line numbers for the node
        # If `exclude_end` is `true`, then the range will be exclusive.
        #
        # Assume that `node` corresponds to the following array literal:
        #
        #   [
        #     :foo,
        #     :bar
        #   ]
        #
        #   node.loc.begin.line_span                         # => 1..1
        #   node.loc.expression.line_span(exclude_end: true) # => 1...4
        def line_span(exclude_end: false)
          ::Range.new(first_line, last_line, exclude_end)
        end
      end
    end
  end
end

::Parser::Source::Range.include ::RuboCop::AST::Ext::Range

Version data entries

64 entries across 60 versions & 9 rubygems

Version Path
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/rubocop-ast-1.23.0/lib/rubocop/ast/ext/range.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/rubocop-ast-1.23.0/lib/rubocop/ast/ext/range.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/rubocop-ast-1.23.0/lib/rubocop/ast/ext/range.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/rubocop-ast-1.21.0/lib/rubocop/ast/ext/range.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/rubocop-ast-1.16.0/lib/rubocop/ast/ext/range.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/rubocop-ast-1.19.1/lib/rubocop/ast/ext/range.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/rubocop-ast-1.16.0/lib/rubocop/ast/ext/range.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/rubocop-ast-1.19.1/lib/rubocop/ast/ext/range.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/rubocop-ast-1.21.0/lib/rubocop/ast/ext/range.rb
rubocop-ast-1.24.0 lib/rubocop/ast/ext/range.rb
rubocop-ast-1.23.0 lib/rubocop/ast/ext/range.rb
rubocop-ast-1.22.0 lib/rubocop/ast/ext/range.rb
rubocop-ast-1.21.0 lib/rubocop/ast/ext/range.rb
rubocop-ast-1.20.1 lib/rubocop/ast/ext/range.rb
rubocop-ast-1.20.0 lib/rubocop/ast/ext/range.rb
rubocop-ast-1.19.1 lib/rubocop/ast/ext/range.rb
rubocop-ast-1.19.0 lib/rubocop/ast/ext/range.rb
rubocop-ast-1.18.0 lib/rubocop/ast/ext/range.rb
rubocop-ast-1.17.0 lib/rubocop/ast/ext/range.rb
op_connect-0.1.2 vendor/bundle/ruby/3.1.0/gems/rubocop-ast-1.16.0/lib/rubocop/ast/ext/range.rb