Skip to main content

cpp_displaced_preprocessor_branch

Function cpp_displaced_preprocessor_branch 

Source
pub fn cpp_displaced_preprocessor_branch<'tree>(
    conditional: Node<'tree>,
) -> Option<Node<'tree>>
Expand description

The first #else/#elif of conditional that tree-sitter displaced into an ERROR inside the conditional’s own branch.

The macro-declaration grammar can read an unterminated end sentinel, the branch directive and the next branch’s begin sentinel as one declaration (END_NS #else BEGIN_NS class C {};, #6325): the #else becomes an ERROR child and the conditional loses its alternative. The token is still the structured branch boundary. Nested conditionals own their own directives, including ones represented only by error-owned #if/#endif tokens, so the walk pairs those the same way cpp_displaced_preprocessor_terminator does.