Move NODES constant into its proper namespace

This commit is contained in:
Sijawusz Pur Rahnama 2023-05-31 13:15:01 +02:00
parent 6e5a9a60b3
commit 85c3db4d74

View file

@ -1,34 +1,6 @@
require "./base_visitor"
module Ameba::AST
# List of nodes to be visited by Ameba's rules.
NODES = {
Alias,
IsA,
Assign,
Call,
Block,
Case,
ClassDef,
ClassVar,
Def,
EnumDef,
ExceptionHandler,
Expressions,
HashLiteral,
If,
InstanceVar,
LibDef,
ModuleDef,
NilLiteral,
StringInterpolation,
Unless,
Var,
When,
While,
Until,
}
# An AST Visitor that traverses the source and allows all nodes
# to be inspected by rules.
#
@ -36,6 +8,34 @@ module Ameba::AST
# visitor = Ameba::AST::NodeVisitor.new(rule, source)
# ```
class NodeVisitor < BaseVisitor
# List of nodes to be visited by Ameba's rules.
NODES = {
Alias,
IsA,
Assign,
Call,
Block,
Case,
ClassDef,
ClassVar,
Def,
EnumDef,
ExceptionHandler,
Expressions,
HashLiteral,
If,
InstanceVar,
LibDef,
ModuleDef,
NilLiteral,
StringInterpolation,
Unless,
Var,
When,
While,
Until,
}
@skip : Array(Crystal::ASTNode.class)?
def initialize(@rule, @source, skip = nil)