Class: Mutant::Mutator::Node Private

Inherits:
Mutant::Mutator show all
Includes:
AST::NamedChildren, AST::NodePredicates, AST::Nodes, AST::Sexp, Unparser::AbstractType, Unparser::Constants
Defined in:
lib/mutant/mutator/node.rb,
lib/mutant/mutator/node/if.rb,
lib/mutant/mutator/node/case.rb,
lib/mutant/mutator/node/mlhs.rb,
lib/mutant/mutator/node/next.rb,
lib/mutant/mutator/node/noop.rb,
lib/mutant/mutator/node/send.rb,
lib/mutant/mutator/node/when.rb,
lib/mutant/mutator/node/begin.rb,
lib/mutant/mutator/node/block.rb,
lib/mutant/mutator/node/break.rb,
lib/mutant/mutator/node/class.rb,
lib/mutant/mutator/node/const.rb,
lib/mutant/mutator/node/index.rb,
lib/mutant/mutator/node/masgn.rb,
lib/mutant/mutator/node/splat.rb,
lib/mutant/mutator/node/super.rb,
lib/mutant/mutator/node/yield.rb,
lib/mutant/mutator/node/binary.rb,
lib/mutant/mutator/node/define.rb,
lib/mutant/mutator/node/kwargs.rb,
lib/mutant/mutator/node/module.rb,
lib/mutant/mutator/node/nthref.rb,
lib/mutant/mutator/node/regopt.rb,
lib/mutant/mutator/node/rescue.rb,
lib/mutant/mutator/node/return.rb,
lib/mutant/mutator/node/sclass.rb,
lib/mutant/mutator/node/zsuper.rb,
lib/mutant/mutator/node/defined.rb,
lib/mutant/mutator/node/generic.rb,
lib/mutant/mutator/node/kwbegin.rb,
lib/mutant/mutator/node/literal.rb,
lib/mutant/mutator/node/op_asgn.rb,
lib/mutant/mutator/node/or_asgn.rb,
lib/mutant/mutator/node/resbody.rb,
lib/mutant/mutator/node/and_asgn.rb,
lib/mutant/mutator/node/argument.rb,
lib/mutant/mutator/node/numblock.rb,
lib/mutant/mutator/node/arguments.rb,
lib/mutant/mutator/node/block_pass.rb,
lib/mutant/mutator/node/literal/nil.rb,
lib/mutant/mutator/node/send/binary.rb,
lib/mutant/mutator/node/literal/hash.rb,
lib/mutant/mutator/node/procarg_zero.rb,
lib/mutant/mutator/node/const_pattern.rb,
lib/mutant/mutator/node/literal/array.rb,
lib/mutant/mutator/node/literal/float.rb,
lib/mutant/mutator/node/literal/range.rb,
lib/mutant/mutator/node/literal/regex.rb,
lib/mutant/mutator/node/literal/string.rb,
lib/mutant/mutator/node/literal/symbol.rb,
lib/mutant/mutator/node/dynamic_literal.rb,
lib/mutant/mutator/node/literal/boolean.rb,
lib/mutant/mutator/node/literal/integer.rb,
lib/mutant/mutator/node/conditional_loop.rb,
lib/mutant/mutator/node/send/conditional.rb,
lib/mutant/mutator/node/match_current_line.rb,
lib/mutant/mutator/node/named_value/access.rb,
lib/mutant/mutator/node/send/attribute_assignment.rb,
lib/mutant/mutator/node/named_value/constant_assignment.rb,
lib/mutant/mutator/node/named_value/variable_assignment.rb

Overview

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

Abstract base class for node mutators

Defined Under Namespace

Modules: NamedValue Classes: AndAsgn, Argument, Arguments, Begin, Binary, Block, BlockPass, Break, Case, Class, ConditionalLoop, Const, ConstPattern, Define, Defined, DynamicLiteral, Generic, If, Index, Kwargs, Kwbegin, Literal, MLHS, MatchCurrentLine, Module, MultipleAssignment, Next, Noop, NthRef, Numblock, OpAsgn, OrAsgn, ProcargZero, Regopt, Resbody, Rescue, Return, Sclass, Send, Splat, Super, When, Yield, ZSuper

Constant Summary collapse

TAUTOLOGY =

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.

->(_input) { true }
REGISTRY =

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.

Registry.new(->(_) { Node::Generic })

Constants included from AST::Nodes

AST::Nodes::N_EMPTY, AST::Nodes::N_EMPTY_SUPER, AST::Nodes::N_FALSE, AST::Nodes::N_INFINITY, AST::Nodes::N_NAN, AST::Nodes::N_NEGATIVE_INFINITY, AST::Nodes::N_NIL, AST::Nodes::N_RAISE, AST::Nodes::N_SELF, AST::Nodes::N_TRUE, AST::Nodes::N_ZSUPER

Instance Attribute Summary

Attributes inherited from Mutant::Mutator

#output

Class Method Summary collapse

Methods included from AST::NamedChildren

included

Methods included from Procto

included

Class Method Details

.mutate(config:, node:, parent: nil) ⇒ Set<Parser::AST::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.

Lookup and invoke dedicated AST mutator

Parameters:

Returns:

  • (Set<Parser::AST::Node>)


25
26
27
28
29
30
31
32
33
34
35
# File 'lib/mutant/mutator/node.rb', line 25

def self.mutate(config:, node:, parent: nil)
  config.ignore_patterns.each do |pattern|
    return Set.new if pattern.match?(node)
  end

  self::REGISTRY.lookup(node.type).call(
    config:,
    input:  node,
    parent:
  )
end