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