Tweak comments in AST::Util

This commit is contained in:
Sijawusz Pur Rahnama 2022-11-15 17:41:53 +01:00
parent 2fb37da80f
commit 76a4209706

View file

@ -91,7 +91,7 @@ module Ameba::AST::Util
node_lines.join('\n')
end
# Returns true if node is a flow command, false - otherwise.
# Returns `true` if node is a flow command, `false` otherwise.
# Node represents a flow command if it is a control expression,
# or special call node that interrupts execution (i.e. raise, exit, abort).
def flow_command?(node, in_loop)
@ -107,7 +107,7 @@ module Ameba::AST::Util
end
end
# Returns true if node is a flow expression, false if not.
# Returns `true` if node is a flow expression, `false` if not.
# Node represents a flow expression if it is full-filled by a flow command.
#
# For example, this node is a flow expression, because each branch contains
@ -159,25 +159,25 @@ module Ameba::AST::Util
nodes.all? { |exp| flow_expression? exp, in_loop }
end
# Returns true if node represents `raise` method call.
# Returns `true` if node represents `raise` method call.
def raise?(node)
node.is_a?(Crystal::Call) &&
node.name == "raise" && node.args.size == 1 && node.obj.nil?
end
# Returns true if node represents `exit` method call.
# Returns `true` if node represents `exit` method call.
def exit?(node)
node.is_a?(Crystal::Call) &&
node.name == "exit" && node.args.size <= 1 && node.obj.nil?
end
# Returns true if node represents `abort` method call.
# Returns `true` if node represents `abort` method call.
def abort?(node)
node.is_a?(Crystal::Call) &&
node.name == "abort" && node.args.size <= 2 && node.obj.nil?
end
# Returns true if node represents a loop.
# Returns `true` if node represents a loop.
def loop?(node)
case node
when Crystal::While, Crystal::Until