MCPcopy Create free account
hub / github.com/arialang/aria / tree_to_string_impl

Function tree_to_string_impl

lsp/src/parser.rs:1376–1414  ·  view source on GitHub ↗
(
        node: &SyntaxNode,
        depth: usize,
        index: &CompressedIndex,
        result: &mut Vec<String>,
    )

Source from the content-addressed store, hash-verified

1374 }
1375
1376 fn tree_to_string_impl(
1377 node: &SyntaxNode,
1378 depth: usize,
1379 index: &CompressedIndex,
1380 result: &mut Vec<String>,
1381 ) {
1382 let indent = " ".repeat(depth);
1383 if let Some((s, e)) = index.node_range(node) {
1384 result.push(format!("{}{:?}@{}..{}", indent, node.kind(), s, e));
1385 } else {
1386 // empty node
1387 result.push(format!("{}{:?}@0..0", indent, node.kind()));
1388 }
1389
1390 for child in node.children_with_tokens() {
1391 match child {
1392 rowan::NodeOrToken::Node(child_node) => {
1393 tree_to_string_impl(&child_node, depth + 1, index, result);
1394 }
1395 rowan::NodeOrToken::Token(token) => {
1396 use crate::lexer::SyntaxKind as K;
1397 if matches!(token.kind(), K::Whitespace | K::LineComment) {
1398 continue;
1399 }
1400 let token_indent = " ".repeat(depth + 1);
1401 if let Some((s, e)) = index.token_range(&token) {
1402 result.push(format!(
1403 "{}{:?}@{}..{} {:?}",
1404 token_indent,
1405 token.kind(),
1406 s,
1407 e,
1408 token.text()
1409 ));
1410 }
1411 }
1412 }
1413 }
1414 }
1415
1416 fn expect_tree(input: &str, lines: &[&str]) {
1417 let node = parse(input).syntax();

Callers 1

tree_to_stringFunction · 0.85

Calls 3

node_rangeMethod · 0.80
token_rangeMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…