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)
| 322 | /// createNode (tree-sitter.ts): id, qualified name from the scope stack, |
| 323 | /// contains edge from the parent scope, value-ref bookkeeping. |
| 324 | fn create_node(&mut self, kind: &'static str, name: &str, node: Node<'t>, extra: Extra) -> Option<u32> { |
| 325 | if name.is_empty() { |
| 326 | return None; |
| 327 | } |
| 328 | let start_line = self.line_of(node); |
| 329 | let id = ids::node_id(self.file_path, kind, name, start_line); |
| 330 | |
| 331 | // endLine body extension: resolveBody only (TS/JS: function-valued |
| 332 | // class fields whose body nests in the arrow / HOF-wrapped arrow). |
| 333 | let mut end_line = node.end_position().row as u32 + 1; |
| 334 | if (kind == "function" || kind == "method") && matches!(node.kind(), "public_field_definition" | "field_definition") |
| 335 | { |
| 336 | if let Some(body) = resolve_field_body(node) { |
| 337 | let be = body.end_position().row as u32 + 1; |
| 338 | if be > end_line { |
| 339 | end_line = be; |
| 340 | } |
| 341 | } |
| 342 | } |
| 343 | |
| 344 | let qualified = extra.qualified_name.unwrap_or_else(|| { |
| 345 | let mut parts: Vec<&str> = Vec::new(); |
| 346 | for s in &self.stack { |
| 347 | if s.kind != "file" { |
| 348 | parts.push(&s.name); |
| 349 | } |
| 350 | } |
| 351 | let mut qn = parts.join("::"); |
| 352 | if !qn.is_empty() { |
| 353 | qn.push_str("::"); |
| 354 | } |
| 355 | qn.push_str(name); |
| 356 | qn |
| 357 | }); |
| 358 | |
| 359 | let mut flags = BoolFlags::default(); |
| 360 | if let Some(v) = extra.is_exported { |
| 361 | flags.set(FLAG_IS_EXPORTED, v); |
| 362 | } |
| 363 | if let Some(v) = extra.is_async { |
| 364 | flags.set(FLAG_IS_ASYNC, v); |
| 365 | } |
| 366 | if let Some(v) = extra.is_static { |
| 367 | flags.set(FLAG_IS_STATIC, v); |
| 368 | } |
| 369 | |
| 370 | let name_ref = self.arena.put(name); |
| 371 | let qn_ref = self.arena.put(&qualified); |
| 372 | let id_ref = self.arena.put(&id); |
| 373 | let doc_ref = opt_str(&mut self.arena, extra.docstring.as_deref()); |
| 374 | let sig_ref = opt_str(&mut self.arena, extra.signature.as_deref()); |
| 375 | let row = self.tables.push_node(&NodeRow { |
| 376 | kind: node_kind_index(kind).unwrap(), |
| 377 | visibility: extra.visibility.unwrap_or(0), |
| 378 | flags, |
| 379 | start_line, |
| 380 | end_line, |
| 381 | start_column: self.col_of(node), |
no test coverage detected