#![allow(clippy::wildcard_imports, clippy::enum_glob_use)]
use super::*;
use crate::lang_helpers::doc_comment::{node_bytes, pod_comment_region};
use crate::lang_helpers::perl::perl_bareword_is_call;
impl Checker for PerlCode {
fn is_comment(node: &Node) -> bool {
matches!(node.kind_id().into(), Perl::Comments | Perl::PodStatement)
}
const DOC_COMMENTS_IN_FUNCTION_BODIES: bool = true;
fn is_doc_comment(node: &Node, code: &[u8]) -> bool {
node.kind_id() == Perl::PodStatement && !pod_comment_region(node_bytes(node, code))
}
fn is_func_space(node: &Node) -> bool {
matches!(
node.kind_id().into(),
Perl::SourceFile
| Perl::FunctionDefinition
| Perl::FunctionDefinitionWithoutSub
| Perl::AnonymousFunction
)
}
fn is_func<'a>(node: &Node<'a>, _ancestors: Ancestors<'a, '_>) -> bool {
matches!(
node.kind_id().into(),
Perl::FunctionDefinition | Perl::FunctionDefinitionWithoutSub
)
}
fn is_closure<'a>(node: &Node<'a>, _ancestors: Ancestors<'a, '_>) -> bool {
node.kind_id() == Perl::AnonymousFunction
}
fn is_call(node: &Node) -> bool {
matches!(
node.kind_id().into(),
Perl::CallExpressionWithSpacedArgs
| Perl::CallExpressionWithSub
| Perl::CallExpressionWithArgsWithBrackets
| Perl::CallExpressionWithVariable
| Perl::CallExpressionWithBareword
| Perl::CallExpressionRecursive
| Perl::MethodInvocation
)
}
fn is_call_with_code<'a>(node: &Node<'a>, _code: &[u8], ancestors: Ancestors<'a, '_>) -> bool {
Self::is_call(node)
&& (node.kind_id() != Perl::CallExpressionWithBareword as u16
|| perl_bareword_is_call(node, ancestors))
}
fn is_non_arg(node: &Node) -> bool {
matches!(
node.kind_id().into(),
Perl::LPAREN | Perl::COMMA | Perl::RPAREN | Perl::FatComma | Perl::NormalComma
)
}
impl_simple_is_string!(
Perl,
StringSingleQuoted,
StringDoubleQuoted,
StringQQuoted,
StringQqQuoted,
BacktickQuoted,
CommandQxQuoted,
HeredocBodyStatement,
);
impl_is_else_if_clause!(Perl, ElsifClause);
}