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

Function tokens

atomic-semantic/src/source.rs:279–309  ·  view source on GitHub ↗
(
    root: Node<'_>,
    source: &str,
    skip_body: Option<usize>,
    skip_functions: bool,
)

Source from the content-addressed store, hash-verified

277}
278
279fn tokens(
280 root: Node<'_>,
281 source: &str,
282 skip_body: Option<usize>,
283 skip_functions: bool,
284) -> Vec<String> {
285 let mut result = Vec::new();
286 let mut stack = vec![root];
287 while let Some(node) = stack.pop() {
288 if node.kind().contains("comment")
289 || Some(node.id()) == skip_body
290 || (skip_functions && callable(node))
291 {
292 continue;
293 }
294 if node.child_count() == 0 {
295 if !text(node, source).trim().is_empty() {
296 result.push(text(node, source).into());
297 }
298 } else {
299 let mut cursor = node.walk();
300 stack.extend(
301 node.children(&mut cursor)
302 .collect::<Vec<_>>()
303 .into_iter()
304 .rev(),
305 );
306 }
307 }
308 result
309}
310
311fn binding_names(root: Node<'_>, source: &str, names: &mut BTreeSet<String>) {
312 let mut stack = vec![root];

Callers 1

from_treeMethod · 0.85

Calls 12

child_countMethod · 0.80
extendMethod · 0.80
childrenMethod · 0.80
callableFunction · 0.70
textFunction · 0.70
containsMethod · 0.45
kindMethod · 0.45
idMethod · 0.45
is_emptyMethod · 0.45
pushMethod · 0.45
walkMethod · 0.45
into_iterMethod · 0.45

Tested by

no test coverage detected