use super::{SyntaxNode, SyntaxToken};
use crate::lex::SyntaxKind;
pub(crate) fn is_block_scalar(node: &SyntaxNode) -> bool {
node.kind() == SyntaxKind::SCALAR
&& node
.first_token()
.is_some_and(|t| matches!(t.kind(), SyntaxKind::PIPE | SyntaxKind::GREATER))
}
pub(crate) fn is_quoted_scalar(token: &SyntaxToken) -> bool {
token.kind() == SyntaxKind::STRING && token.text().starts_with(['"', '\''])
}
pub(crate) fn starts_a_flow_collection(node: &SyntaxNode) -> bool {
node.children_with_tokens()
.take_while(|c| c.as_token().is_some())
.any(|c| matches!(c.kind(), SyntaxKind::LEFT_BRACE | SyntaxKind::LEFT_BRACKET))
}
pub(crate) fn in_flow_collection(node: &SyntaxNode) -> bool {
node.ancestors().skip(1).any(|a| {
matches!(a.kind(), SyntaxKind::MAPPING | SyntaxKind::SEQUENCE)
&& starts_a_flow_collection(&a)
})
}