(&mut self, kind: &'static str, name: &str, node: Node<'t>, extra: Extra)
| 183 | } |
| 184 | |
| 185 | fn create_node(&mut self, kind: &'static str, name: &str, node: Node<'t>, extra: Extra) -> Option<u32> { |
| 186 | if name.is_empty() { |
| 187 | return None; |
| 188 | } |
| 189 | let start_line = self.line_of(node); |
| 190 | let id = ids::node_id(self.file_path, kind, name, start_line); |
| 191 | let end_line = node.end_position().row as u32 + 1; |
| 192 | |
| 193 | let qualified = { |
| 194 | let mut parts: Vec<&str> = Vec::new(); |
| 195 | for s in &self.stack { |
| 196 | if s.kind != "file" { |
| 197 | parts.push(&s.name); |
| 198 | } |
| 199 | } |
| 200 | let mut qn = parts.join("::"); |
| 201 | if !qn.is_empty() { |
| 202 | qn.push_str("::"); |
| 203 | } |
| 204 | qn.push_str(name); |
| 205 | qn |
| 206 | }; |
| 207 | |
| 208 | let mut flags = BoolFlags::default(); |
| 209 | if let Some(v) = extra.is_async { |
| 210 | flags.set(FLAG_IS_ASYNC, v); |
| 211 | } |
| 212 | if let Some(v) = extra.is_static { |
| 213 | flags.set(FLAG_IS_STATIC, v); |
| 214 | } |
| 215 | let name_ref = self.arena.put(name); |
| 216 | let qn_ref = self.arena.put(&qualified); |
| 217 | let id_ref = self.arena.put(&id); |
| 218 | let doc_ref = opt_str(&mut self.arena, extra.docstring.as_deref()); |
| 219 | let sig_ref = opt_str(&mut self.arena, extra.signature.as_deref()); |
| 220 | let row = self.tables.push_node(&NodeRow { |
| 221 | kind: node_kind_index(kind).unwrap(), |
| 222 | visibility: 0, |
| 223 | flags, |
| 224 | start_line, |
| 225 | end_line, |
| 226 | start_column: self.col_of(node), |
| 227 | end_column: self.end_col_of(node), |
| 228 | name: name_ref, |
| 229 | qualified_name: qn_ref, |
| 230 | id: id_ref, |
| 231 | docstring: doc_ref, |
| 232 | signature: sig_ref, |
| 233 | decorators: NONE_STR, |
| 234 | type_parameters: NONE_STR, |
| 235 | return_type: NONE_STR, |
| 236 | extra_json: NONE_STR, |
| 237 | }); |
| 238 | self.node_ids.push(id); |
| 239 | |
| 240 | let parent_row = self.top_row(); |
| 241 | self.tables.push_edge(&EdgeRow { |
| 242 | source_idx: parent_row, |
no test coverage detected