Class: RuboCop::AST::Token
Relationships & Source Files | |
Inherits: | Object |
Defined in: | lib/rubocop/ast/token.rb |
Overview
A basic wrapper around Parser’s tokens.
Constant Summary
-
LEFT_CURLY_TYPES =
# File 'lib/rubocop/ast/token.rb', line 8%i[tLCURLY tLAMBEG].freeze
-
LEFT_PAREN_TYPES =
# File 'lib/rubocop/ast/token.rb', line 7%i[tLPAREN tLPAREN2].freeze
Class Method Summary
Instance Attribute Summary
- #comma? ⇒ Boolean readonly
-
#comment? ⇒ Boolean
readonly
Type Predicates.
- #dot? ⇒ Boolean readonly
- #end? ⇒ Boolean readonly
- #equal_sign? ⇒ Boolean readonly
- #left_array_bracket? ⇒ Boolean readonly
- #left_brace? ⇒ Boolean readonly
- #left_bracket? ⇒ Boolean readonly
- #left_curly_brace? ⇒ Boolean readonly
- #left_parens? ⇒ Boolean readonly
- #left_ref_bracket? ⇒ Boolean readonly
- #new_line? ⇒ Boolean readonly
- #pos readonly
- #regexp_dots? ⇒ Boolean readonly
- #rescue_modifier? ⇒ Boolean readonly
- #right_bracket? ⇒ Boolean readonly
- #right_curly_brace? ⇒ Boolean readonly
- #right_parens? ⇒ Boolean readonly
- #semicolon? ⇒ Boolean readonly
-
#space_after? ⇒ Boolean
readonly
Checks if there is whitespace after token.
-
#space_before? ⇒ Boolean
readonly
Checks if there is whitespace before token.
- #text readonly
- #type readonly
Instance Method Summary
Constructor Details
.new(pos, type, text) ⇒ Token
Class Method Details
.from_parser_token(parser_token)
[ GitHub ]Instance Attribute Details
#comma? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/rubocop/ast/token.rb', line 102
def comma? type == :tCOMMA end
#comment? ⇒ Boolean
(readonly)
Type Predicates
# File 'lib/rubocop/ast/token.rb', line 58
def comment? type == :tCOMMENT end
#dot? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/rubocop/ast/token.rb', line 106
def dot? type == :tDOT end
#end? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/rubocop/ast/token.rb', line 118
def end? type == :kEND end
#equal_sign? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/rubocop/ast/token.rb', line 122
def equal_sign? %i[tEQL tOP_ASGN].include?(type) end
#left_array_bracket? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/rubocop/ast/token.rb', line 66
def left_array_bracket? type == :tLBRACK end
#left_brace? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/rubocop/ast/token.rb', line 82
def left_brace? type == :tLBRACE end
#left_bracket? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/rubocop/ast/token.rb', line 74
def left_bracket? %i[tLBRACK tLBRACK2].include?(type) end
#left_curly_brace? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/rubocop/ast/token.rb', line 86
def left_curly_brace? LEFT_CURLY_TYPES.include?(type) end
#left_parens? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/rubocop/ast/token.rb', line 94
def left_parens? LEFT_PAREN_TYPES.include?(type) end
#left_ref_bracket? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/rubocop/ast/token.rb', line 70
def left_ref_bracket? type == :tLBRACK2 end
#new_line? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/rubocop/ast/token.rb', line 126
def new_line? type == :tNL end
#pos (readonly)
[ GitHub ]
#regexp_dots? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/rubocop/ast/token.rb', line 110
def regexp_dots? %i[tDOT2 tDOT3].include?(type) end
#rescue_modifier? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/rubocop/ast/token.rb', line 114
def rescue_modifier? type == :kRESCUE_MOD end
#right_bracket? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/rubocop/ast/token.rb', line 78
def right_bracket? type == :tRBRACK end
#right_curly_brace? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/rubocop/ast/token.rb', line 90
def right_curly_brace? type == :tRCURLY end
#right_parens? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/rubocop/ast/token.rb', line 98
def right_parens? type == :tRPAREN end
#semicolon? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'lib/rubocop/ast/token.rb', line 62
def semicolon? type == :tSEMI end
#space_after? ⇒ Boolean
(readonly)
Checks if there is whitespace after token
#space_before? ⇒ Boolean
(readonly)
Checks if there is whitespace before token
#text (readonly)
[ GitHub ]#type (readonly)
[ GitHub ]Instance Method Details
#begin_pos
[ GitHub ]# File 'lib/rubocop/ast/token.rb', line 33
def begin_pos @pos.begin_pos end
#column
[ GitHub ]# File 'lib/rubocop/ast/token.rb', line 29
def column @pos.column end
#end_pos
[ GitHub ]# File 'lib/rubocop/ast/token.rb', line 37
def end_pos @pos.end_pos end
#line
[ GitHub ]# File 'lib/rubocop/ast/token.rb', line 25
def line @pos.line end