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