(
root: Node<'_>,
source: &str,
skip_body: Option<usize>,
skip_functions: bool,
)
| 277 | } |
| 278 | |
| 279 | fn 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 | |
| 311 | fn binding_names(root: Node<'_>, source: &str, names: &mut BTreeSet<String>) { |
| 312 | let mut stack = vec![root]; |
no test coverage detected