Ameba::AST::NodeVisitor - ameba 1.6.4-1-dev

# class Ameba::AST::NodeVisitor

- Ameba::AST::NodeVisitor
- Ameba::AST::BaseVisitor
- Crystal::Visitor
- Reference
- Object

##
Overview

An AST Visitor that traverses the source and allows all nodes to be inspected by rules.

    visitor = Ameba::AST::NodeVisitor.new(rule, source)

##
Defined in:

ameba/ast/visitors/node_visitor.cr

##
Constant Summary

NODES = `{Alias, Assign, Block, Call, Case, ClassDef, ClassVar, Def, EnumDef, ExceptionHandler, Expressions, HashLiteral, If, InstanceVar, IsA, LibDef, ModuleDef, MultiAssign, NilLiteral, StringInterpolation, Unless, Until, Var, When, While}`

  List of nodes to be visited by Ameba's rules.

##
Constructors

- .new(rule, source, *, skip : Category)
- .new(rule, source, *, skip : Array | Nil = nil)

##
Class Method Summary

- .category_to_node_classes(category : Category)

##
Instance Method Summary

- #visit(node : Crystal::VisibilityModifier)
- #visit(node : Crystal::Alias)

  A visit callback for `Crystal::Alias` node.

- #visit(node : Crystal::Assign)

  A visit callback for `Crystal::Assign` node.

- #visit(node : Crystal::Block)

  A visit callback for `Crystal::Block` node.

- #visit(node : Crystal::Call)

  A visit callback for `Crystal::Call` node.

- #visit(node : Crystal::Case)

  A visit callback for `Crystal::Case` node.

- #visit(node : Crystal::ClassDef)

  A visit callback for `Crystal::ClassDef` node.

- #visit(node : Crystal::ClassVar)

  A visit callback for `Crystal::ClassVar` node.

- #visit(node : Crystal::Def)

  A visit callback for `Crystal::Def` node.

- #visit(node : Crystal::EnumDef)

  A visit callback for `Crystal::EnumDef` node.

- #visit(node : Crystal::ExceptionHandler)

  A visit callback for `Crystal::ExceptionHandler` node.

- #visit(node : Crystal::Expressions)

  A visit callback for `Crystal::Expressions` node.

- #visit(node : Crystal::HashLiteral)

  A visit callback for `Crystal::HashLiteral` node.

- #visit(node : Crystal::If)

  A visit callback for `Crystal::If` node.

- #visit(node : Crystal::InstanceVar)

  A visit callback for `Crystal::InstanceVar` node.

- #visit(node : Crystal::IsA)

  A visit callback for `Crystal::IsA` node.

- #visit(node : Crystal::LibDef)

  A visit callback for `Crystal::LibDef` node.

- #visit(node : Crystal::ModuleDef)

  A visit callback for `Crystal::ModuleDef` node.

- #visit(node : Crystal::MultiAssign)

  A visit callback for `Crystal::MultiAssign` node.

- #visit(node : Crystal::NilLiteral)

  A visit callback for `Crystal::NilLiteral` node.

- #visit(node : Crystal::StringInterpolation)

  A visit callback for `Crystal::StringInterpolation` node.

- #visit(node : Crystal::Unless)

  A visit callback for `Crystal::Unless` node.

- #visit(node : Crystal::Until)

  A visit callback for `Crystal::Until` node.

- #visit(node : Crystal::Var)

  A visit callback for `Crystal::Var` node.

- #visit(node : Crystal::When)

  A visit callback for `Crystal::When` node.

- #visit(node : Crystal::While)

  A visit callback for `Crystal::While` node.

- #visit(node)

### Instance methods inherited from class `Ameba::AST::BaseVisitor`

visit(node : Crystal::ASTNode) visit

### Constructor methods inherited from class `Ameba::AST::BaseVisitor`

new(rule : Ameba::Rule::Base, source : Ameba::Source) new

##
Constructor Detail

def self.new(rule, source, *, skip : Category) #
def self.new(rule, source, *, skip : Array | Nil = nil) #

##
Class Method Detail

def self.category_to_node_classes(category : Category) #

##
Instance Method Detail

def visit(node : Crystal::VisibilityModifier) #
def visit(node : Crystal::Alias) #

A visit callback for `Crystal::Alias` node.

Returns `true` if the child nodes should be traversed as well, `false` otherwise.

def visit(node : Crystal::Assign) #

A visit callback for `Crystal::Assign` node.

Returns `true` if the child nodes should be traversed as well, `false` otherwise.

def visit(node : Crystal::Block) #

A visit callback for `Crystal::Block` node.

Returns `true` if the child nodes should be traversed as well, `false` otherwise.

def visit(node : Crystal::Call) #

A visit callback for `Crystal::Call` node.

Returns `true` if the child nodes should be traversed as well, `false` otherwise.

def visit(node : Crystal::Case) #

A visit callback for `Crystal::Case` node.

Returns `true` if the child nodes should be traversed as well, `false` otherwise.

def visit(node : Crystal::ClassDef) #

A visit callback for `Crystal::ClassDef` node.

Returns `true` if the child nodes should be traversed as well, `false` otherwise.

def visit(node : Crystal::ClassVar) #

A visit callback for `Crystal::ClassVar` node.

Returns `true` if the child nodes should be traversed as well, `false` otherwise.

def visit(node : Crystal::Def) #

A visit callback for `Crystal::Def` node.

Returns `true` if the child nodes should be traversed as well, `false` otherwise.

def visit(node : Crystal::EnumDef) #

A visit callback for `Crystal::EnumDef` node.

Returns `true` if the child nodes should be traversed as well, `false` otherwise.

def visit(node : Crystal::ExceptionHandler) #

A visit callback for `Crystal::ExceptionHandler` node.

Returns `true` if the child nodes should be traversed as well, `false` otherwise.

def visit(node : Crystal::Expressions) #

A visit callback for `Crystal::Expressions` node.

Returns `true` if the child nodes should be traversed as well, `false` otherwise.

def visit(node : Crystal::HashLiteral) #

A visit callback for `Crystal::HashLiteral` node.

Returns `true` if the child nodes should be traversed as well, `false` otherwise.

def visit(node : Crystal::If) #

A visit callback for `Crystal::If` node.

Returns `true` if the child nodes should be traversed as well, `false` otherwise.

def visit(node : Crystal::InstanceVar) #

A visit callback for `Crystal::InstanceVar` node.

Returns `true` if the child nodes should be traversed as well, `false` otherwise.

def visit(node : Crystal::IsA) #

A visit callback for `Crystal::IsA` node.

Returns `true` if the child nodes should be traversed as well, `false` otherwise.

def visit(node : Crystal::LibDef) #

A visit callback for `Crystal::LibDef` node.

Returns `true` if the child nodes should be traversed as well, `false` otherwise.

def visit(node : Crystal::ModuleDef) #

A visit callback for `Crystal::ModuleDef` node.

Returns `true` if the child nodes should be traversed as well, `false` otherwise.

def visit(node : Crystal::MultiAssign) #

A visit callback for `Crystal::MultiAssign` node.

Returns `true` if the child nodes should be traversed as well, `false` otherwise.

def visit(node : Crystal::NilLiteral) #

A visit callback for `Crystal::NilLiteral` node.

Returns `true` if the child nodes should be traversed as well, `false` otherwise.

def visit(node : Crystal::StringInterpolation) #

A visit callback for `Crystal::StringInterpolation` node.

Returns `true` if the child nodes should be traversed as well, `false` otherwise.

def visit(node : Crystal::Unless) #

A visit callback for `Crystal::Unless` node.

Returns `true` if the child nodes should be traversed as well, `false` otherwise.

def visit(node : Crystal::Until) #

A visit callback for `Crystal::Until` node.

Returns `true` if the child nodes should be traversed as well, `false` otherwise.

def visit(node : Crystal::Var) #

A visit callback for `Crystal::Var` node.

Returns `true` if the child nodes should be traversed as well, `false` otherwise.

def visit(node : Crystal::When) #

A visit callback for `Crystal::When` node.

Returns `true` if the child nodes should be traversed as well, `false` otherwise.

def visit(node : Crystal::While) #

A visit callback for `Crystal::While` node.

Returns `true` if the child nodes should be traversed as well, `false` otherwise.

def visit(node) #