#![allow(clippy::wildcard_imports, clippy::enum_glob_use)]
use super::*;
pub(crate) fn is_stabby_lambda_body<'a>(node: &Node<'a>, ancestors: Ancestors<'a, '_>) -> bool {
ancestors
.parent(node)
.is_some_and(|parent| parent.kind_id() == Ruby::Lambda)
}
impl Checker for RubyCode {
fn is_comment(node: &Node) -> bool {
node.kind_id() == Ruby::Comment
}
fn is_func_space(node: &Node) -> bool {
matches!(
node.kind_id().into(),
Ruby::Program
| Ruby::Method
| Ruby::SingletonMethod
| Ruby::Lambda
| Ruby::Block
| Ruby::DoBlock
| Ruby::Class
| Ruby::SingletonClass
| Ruby::Module
)
}
fn is_func_space_with_code<'a>(
node: &Node<'a>,
_code: &[u8],
ancestors: Ancestors<'a, '_>,
) -> bool {
Self::is_func_space(node)
&& !(matches!(node.kind_id().into(), Ruby::Block | Ruby::DoBlock)
&& is_stabby_lambda_body(node, ancestors))
}
fn is_func<'a>(node: &Node<'a>, _ancestors: Ancestors<'a, '_>) -> bool {
matches!(node.kind_id().into(), Ruby::Method | Ruby::SingletonMethod)
}
fn is_closure<'a>(node: &Node<'a>, ancestors: Ancestors<'a, '_>) -> bool {
match node.kind_id().into() {
Ruby::Lambda => true,
Ruby::Block | Ruby::DoBlock => !is_stabby_lambda_body(node, ancestors),
_ => false,
}
}
fn is_call(node: &Node) -> bool {
matches!(
node.kind_id().into(),
Ruby::Call | Ruby::Call2 | Ruby::Call3 | Ruby::Call4
)
}
fn is_non_arg(node: &Node) -> bool {
matches!(
node.kind_id().into(),
Ruby::LPAREN
| Ruby::LPAREN2
| Ruby::RPAREN
| Ruby::RPAREN2
| Ruby::COMMA
| Ruby::SEMI
| Ruby::PIPE
)
}
impl_simple_is_string!(
Ruby,
String,
ChainedString,
BareString,
Subshell,
Regex,
HeredocBody,
DelimitedSymbol,
SimpleSymbol,
StringArray,
SymbolArray,
Character,
);
impl_is_else_if_clause!(Ruby, Elsif);
}