Returns the text of the Nth `sym_lit` child (0-indexed among named children).
(state: &ExtractionState, node: TsNode<'_>, n: usize)
| 410 | |
| 411 | /// Returns the text of the Nth `sym_lit` child (0-indexed among named children). |
| 412 | fn nth_sym(state: &ExtractionState, node: TsNode<'_>, n: usize) -> Option<String> { |
| 413 | let mut count = 0; |
| 414 | let mut cursor = node.walk(); |
| 415 | if cursor.goto_first_child() { |
| 416 | loop { |
| 417 | let child = cursor.node(); |
| 418 | if child.kind() == "sym_lit" { |
| 419 | if count == n { |
| 420 | return Some(state.node_text(child)); |
| 421 | } |
| 422 | count += 1; |
| 423 | } |
| 424 | if !cursor.goto_next_sibling() { |
| 425 | break; |
| 426 | } |
| 427 | } |
| 428 | } |
| 429 | None |
| 430 | } |
| 431 | |
| 432 | /// Returns the first `str_lit` child, used for docstrings. |
| 433 | fn extract_string_child(state: &ExtractionState, node: TsNode<'_>) -> Option<String> { |