typst_analyzer_analysis/
node.rs1use typst_syntax::{LinkedNode, SyntaxKind, SyntaxNode};
2
3pub fn node_walker(pos: usize, ast: &SyntaxNode) -> Vec<SyntaxKind> {
6 let linked_root = LinkedNode::new(ast);
7 let current_node = linked_root.leaf_at(pos, typst_syntax::Side::Before);
9 let mut nodes: Vec<SyntaxKind> = Vec::new();
12 if let Some(node) = current_node {
13 nodes.push(node.clone().kind());
14 let mut parent = node.parent();
16 while let Some(p) = parent {
17 nodes.push(p.clone().kind());
18 parent = p.parent();
19 }
20 }
21 nodes
22}