(file_path: &str, source: &str)
| 271 | } |
| 272 | |
| 273 | pub fn extract(file_path: &str, source: &str) -> Result<EmitOut, String> { |
| 274 | let grammar = crate::langs::grammar_for("dart").ok_or("no dart grammar")?; |
| 275 | let t0 = std::time::Instant::now(); |
| 276 | let mut parser = Parser::new(); |
| 277 | parser |
| 278 | .set_language(&grammar) |
| 279 | .map_err(|e| format!("set_language(dart) failed: {e}"))?; |
| 280 | let tree = crate::parse_budget::parse(&mut parser, source)?; |
| 281 | if tree.root_node().has_error() { |
| 282 | return Err("defer: parse tree contains errors — wasm recovery is canonical".to_string()); |
| 283 | } |
| 284 | |
| 285 | let mut w = Walker { |
| 286 | src: source, |
| 287 | file_path, |
| 288 | line_starts: util::line_starts(source), |
| 289 | arena: Arena::default(), |
| 290 | node_id_allocator: ids::NodeIdAllocator::default(), |
| 291 | tables: Tables::default(), |
| 292 | stack: Vec::new(), |
| 293 | node_ids: Vec::new(), |
| 294 | defined_fn_names: HashSet::new(), |
| 295 | imported_names: HashSet::new(), |
| 296 | fn_ref_cands: Vec::new(), |
| 297 | fs_values: HashMap::new(), |
| 298 | fs_value_counts: HashMap::new(), |
| 299 | value_scopes: Vec::new(), |
| 300 | }; |
| 301 | |
| 302 | // File node (tree-sitter.ts:508-521). |
| 303 | let line_count = source.bytes().filter(|b| *b == b'\n').count() as u32 + 1; |
| 304 | let base_name = file_path.rsplit(['/', '\\']).next().unwrap_or(file_path); |
| 305 | let mut flags = BoolFlags::default(); |
| 306 | flags.set(FLAG_IS_EXPORTED, false); |
| 307 | let file_id = w.arena.put(&ids::file_node_id(file_path)); |
| 308 | let name_ref = w.arena.put(base_name); |
| 309 | let qn_ref = w.arena.put(file_path); |
| 310 | w.tables.push_node(&NodeRow { |
| 311 | kind: node_kind_index("file").unwrap(), |
| 312 | visibility: 0, |
| 313 | flags, |
| 314 | start_line: 1, |
| 315 | end_line: line_count, |
| 316 | start_column: 0, |
| 317 | end_column: 0, |
| 318 | name: name_ref, |
| 319 | qualified_name: qn_ref, |
| 320 | id: file_id, |
| 321 | docstring: NONE_STR, |
| 322 | signature: NONE_STR, |
| 323 | decorators: NONE_STR, |
| 324 | type_parameters: NONE_STR, |
| 325 | return_type: NONE_STR, |
| 326 | extra_json: NONE_STR, |
| 327 | }); |
| 328 | w.node_ids.push(ids::file_node_id(file_path)); |
| 329 | w.stack.push(Scope { row: 0, kind: "file", name: base_name.to_string() }); |
| 330 |
nothing calls this directly
no test coverage detected