Module: RuboCop::AST::BuilderExtensions Private

Included in:
Builder, BuilderPrism
Defined in:
lib/rubocop/ast/builder.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Common functionality between the parser and prism builder

Constant Summary collapse

NODE_MAP =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

{
  and:                 AndNode,
  and_asgn:            AndAsgnNode,
  alias:               AliasNode,
  arg:                 ArgNode,
  blockarg:            ArgNode,
  forward_arg:         ArgNode,
  kwarg:               ArgNode,
  kwoptarg:            ArgNode,
  kwrestarg:           ArgNode,
  optarg:              ArgNode,
  restarg:             ArgNode,
  shadowarg:           ArgNode,
  args:                ArgsNode,
  array:               ArrayNode,
  lvasgn:              AsgnNode,
  ivasgn:              AsgnNode,
  cvasgn:              AsgnNode,
  gvasgn:              AsgnNode,
  block:               BlockNode,
  numblock:            BlockNode,
  itblock:             BlockNode,
  break:               BreakNode,
  case_match:          CaseMatchNode,
  casgn:               CasgnNode,
  case:                CaseNode,
  class:               ClassNode,
  complex:             ComplexNode,
  const:               ConstNode,
  def:                 DefNode,
  defined?:            DefinedNode,
  defs:                DefNode,
  dstr:                DstrNode,
  ensure:              EnsureNode,
  for:                 ForNode,
  forward_args:        ForwardArgsNode,
  forwarded_kwrestarg: KeywordSplatNode,
  float:               FloatNode,
  hash:                HashNode,
  if:                  IfNode,
  in_pattern:          InPatternNode,
  int:                 IntNode,
  index:               IndexNode,
  indexasgn:           IndexasgnNode,
  irange:              RangeNode,
  erange:              RangeNode,
  kwargs:              HashNode,
  kwbegin:             KeywordBeginNode,
  kwsplat:             KeywordSplatNode,
  lambda:              LambdaNode,
  masgn:               MasgnNode,
  mlhs:                MlhsNode,
  module:              ModuleNode,
  next:                NextNode,
  op_asgn:             OpAsgnNode,
  or_asgn:             OrAsgnNode,
  or:                  OrNode,
  pair:                PairNode,
  procarg0:            Procarg0Node,
  rational:            RationalNode,
  regexp:              RegexpNode,
  rescue:              RescueNode,
  resbody:             ResbodyNode,
  return:              ReturnNode,
  csend:               CsendNode,
  send:                SendNode,
  str:                 StrNode,
  xstr:                StrNode,
  sclass:              SelfClassNode,
  super:               SuperNode,
  zsuper:              SuperNode,
  sym:                 SymbolNode,
  until:               UntilNode,
  until_post:          UntilNode,
  lvar:                VarNode,
  ivar:                VarNode,
  cvar:                VarNode,
  gvar:                VarNode,
  when:                WhenNode,
  while:               WhileNode,
  while_post:          WhileNode,
  yield:               YieldNode
}.freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



8
9
10
11
# File 'lib/rubocop/ast/builder.rb', line 8

def self.included(base)
  base.emit_forward_arg = true
  base.emit_match_pattern = true
end

Instance Method Details

#n(type, children, source_map) ⇒ Node

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Generates Node from the given information.

Returns:

  • (Node)

    the generated node



101
102
103
# File 'lib/rubocop/ast/builder.rb', line 101

def n(type, children, source_map)
  node_klass(type).new(type, children, location: source_map)
end

#string_value(token) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Overwrite the base method to allow strings with invalid encoding More details here github.com/whitequark/parser/issues/283



107
108
109
# File 'lib/rubocop/ast/builder.rb', line 107

def string_value(token)
  value(token)
end