MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / inventory

Function inventory

atomic-audit/src/extract/mod.rs:160–182  ·  view source on GitHub ↗
(root: Node<'_>)

Source from the content-addressed store, hash-verified

158}
159
160fn inventory(root: Node<'_>) -> Result<Vec<Node<'_>>, String> {
161 let mut result = Vec::new();
162 let mut stack = vec![(root, 0)];
163 while let Some((node, depth)) = stack.pop() {
164 if depth > 256 {
165 return Err("AST nesting budget exceeded".into());
166 }
167 if tokens::comment(node) {
168 continue;
169 }
170 result.push(node);
171 if result.len() > 300_000 {
172 return Err("AST node budget exceeded".into());
173 }
174 stack.extend(
175 tokens::named(node)
176 .into_iter()
177 .rev()
178 .map(|child| (child, depth + 1)),
179 );
180 }
181 Ok(result)
182}
183
184fn parse(
185 source: &Source,

Callers 1

parseFunction · 0.70

Calls 6

commentFunction · 0.85
extendMethod · 0.80
namedFunction · 0.70
pushMethod · 0.45
lenMethod · 0.45
into_iterMethod · 0.45

Tested by

no test coverage detected