createNode (tree-sitter.ts): id, qualified name from the scope stack, contains edge from the parent scope, value-ref bookkeeping.
(&mut self, kind: &'static str, name: &str, node: Node<'t>, extra: Extra)
| 396 | /// createNode (tree-sitter.ts): id, qualified name from the scope stack, |
| 397 | /// contains edge from the parent scope, value-ref bookkeeping. |
| 398 | fn create_node(&mut self, kind: &'static str, name: &str, node: Node<'t>, extra: Extra) -> Option<u32> { |
| 399 | if name.is_empty() { |
| 400 | return None; |
| 401 | } |
| 402 | let start_line = self.line_of(node); |
| 403 | let column = self.col_of(node); |
| 404 | let id = self.node_id_allocator.generate(self.file_path, kind, name, start_line, column); |
| 405 | let value_target = !extra.not_value_target; |
| 406 | |
| 407 | // endLine body extension: resolveBody only (TS/JS: function-valued |
| 408 | // class fields whose body nests in the arrow / HOF-wrapped arrow). |
| 409 | let mut end_line = node.end_position().row as u32 + 1; |
| 410 | if (kind == "function" || kind == "method") && matches!(node.kind(), "public_field_definition" | "field_definition") |
| 411 | { |
| 412 | if let Some(body) = resolve_field_body(node) { |
| 413 | let be = body.end_position().row as u32 + 1; |
| 414 | if be > end_line { |
| 415 | end_line = be; |
| 416 | } |
| 417 | } |
| 418 | } |
| 419 | |
| 420 | let qualified = extra.qualified_name.unwrap_or_else(|| { |
| 421 | let mut parts: Vec<&str> = Vec::new(); |
| 422 | for s in &self.stack { |
| 423 | // A path-hung object literal qualifies what it holds by its |
| 424 | // path (`window.App::init`), which carries its own scope. |
| 425 | if let Some(path) = self.object_path_owners.get(&s.row) { |
| 426 | parts.clear(); |
| 427 | parts.push(path); |
| 428 | continue; |
| 429 | } |
| 430 | if s.kind != "file" { |
| 431 | parts.push(&s.name); |
| 432 | } |
| 433 | } |
| 434 | let mut qn = parts.join("::"); |
| 435 | if !qn.is_empty() { |
| 436 | qn.push_str("::"); |
| 437 | } |
| 438 | qn.push_str(name); |
| 439 | qn |
| 440 | }); |
| 441 | |
| 442 | let mut flags = BoolFlags::default(); |
| 443 | if let Some(v) = extra.is_exported { |
| 444 | flags.set(FLAG_IS_EXPORTED, v); |
| 445 | } |
| 446 | if let Some(v) = extra.is_async { |
| 447 | flags.set(FLAG_IS_ASYNC, v); |
| 448 | } |
| 449 | if let Some(v) = extra.is_static { |
| 450 | flags.set(FLAG_IS_STATIC, v); |
| 451 | } |
| 452 | |
| 453 | let name_ref = self.arena.put(name); |
| 454 | let qn_ref = self.arena.put(&qualified); |
| 455 | let id_ref = self.arena.put(&id); |
no test coverage detected