Make AST::NodeVisitor::Category a flag enum

This commit is contained in:
Sijawusz Pur Rahnama 2023-06-12 21:53:51 +02:00
parent 38b6751bc0
commit c09b36799a

View file

@ -8,6 +8,7 @@ module Ameba::AST
# visitor = Ameba::AST::NodeVisitor.new(rule, source)
# ```
class NodeVisitor < BaseVisitor
@[Flags]
enum Category
Macro
end
@ -43,14 +44,13 @@ module Ameba::AST
@skip : Array(Crystal::ASTNode.class)?
def self.category_to_node_classes(category : Category)
case category
in .macro?
[
([] of Crystal::ASTNode.class).tap do |classes|
classes.push(
Crystal::Macro,
Crystal::MacroExpression,
Crystal::MacroIf,
Crystal::MacroFor,
]
) if category.macro?
end
end