is_raw_block_cst_node

Function is_raw_block_cst_node 

Source
pub fn is_raw_block_cst_node(block: &SyntaxNode) -> bool
Expand description

Check if a CST BLOCK node belongs to a raw block directive (e.g. *_by_lua_block).

Walks up to the parent DIRECTIVE node and checks if its first IDENT token is a raw block directive name.

ยงExamples

use nginx_lint_parser::{parse_string_rowan, is_raw_block_cst_node};
use nginx_lint_parser::syntax_kind::SyntaxKind;

let (root, _) = parse_string_rowan("content_by_lua_block { ngx.say('hi') }");
let directive = root.children().next().unwrap();
let block = directive.children().find(|n| n.kind() == SyntaxKind::BLOCK).unwrap();
assert!(is_raw_block_cst_node(&block));