Module: RuboCop::Ext::RegexpParser::Expression::Base
- Defined in:
- lib/rubocop/ext/regexp_parser.rb
Overview
Add expression
and loc
to all regexp_parser
nodes
Instance Attribute Summary collapse
-
#origin ⇒ Object
Returns the value of attribute origin.
-
#source ⇒ Object
Please remove this
else
branch when support for regexp_parser 1.8 will be dropped.
Instance Method Summary collapse
-
#expression ⇒ Object
Shortcut to
loc.expression
. -
#loc ⇒ Object
E.g.
- #start_index ⇒ Object
Instance Attribute Details
#origin ⇒ Object
Returns the value of attribute origin.
23 24 25 |
# File 'lib/rubocop/ext/regexp_parser.rb', line 23 def origin @origin end |
#source ⇒ Object
Please remove this else
branch when support for regexp_parser 1.8 will be dropped.
It’s for compatibility with regexp_parser 1.8 and will never be maintained.
33 34 35 |
# File 'lib/rubocop/ext/regexp_parser.rb', line 33 def source @source end |
Instance Method Details
#expression ⇒ Object
Shortcut to loc.expression
27 28 29 |
# File 'lib/rubocop/ext/regexp_parser.rb', line 27 def expression @expression ||= origin.adjust(begin_pos: ts, end_pos: ts + full_length) end |
#loc ⇒ Object
E.g. [a-z]2, ^^^ expression ^^ quantifier ^^^ body ^ begin ^ end
Please open issue if you need other locations
61 62 63 |
# File 'lib/rubocop/ext/regexp_parser.rb', line 61 def loc @loc ||= Map.new(expression, **build_location) end |
#start_index ⇒ Object
35 36 37 38 |
# File 'lib/rubocop/ext/regexp_parser.rb', line 35 def start_index # ts is a byte index; convert it to a character index @start_index ||= source.byteslice(0, ts).length end |