MCPcopy Create free account
hub / github.com/douglance/devsql / parse_ts_export_statement

Function parse_ts_export_statement

crates/devsql/src/providers/imports.rs:323–402  ·  view source on GitHub ↗
(
    node: Node,
    source: &str,
    lines: &LineIndex<'_>,
    file_path: &str,
    rows: &mut Vec<ImportRow>,
)

Source from the content-addressed store, hash-verified

321}
322
323fn parse_ts_export_statement(
324 node: Node,
325 source: &str,
326 lines: &LineIndex<'_>,
327 file_path: &str,
328 rows: &mut Vec<ImportRow>,
329) {
330 let Some(module_node) = node.child_by_field_name("source") else {
331 return;
332 };
333 let module = string_literal_value(module_node, source);
334 if module.is_empty() {
335 return;
336 }
337
338 let line_number = lines.line_for_byte(node.start_byte()) as i64;
339 let mut added = 0usize;
340
341 for child in named_children(node) {
342 match child.kind() {
343 "export_clause" => {
344 for spec in named_children(child).into_iter().filter(|n| n.kind() == "export_specifier") {
345 let export_name = spec
346 .child_by_field_name("name")
347 .map(|n| clean_identifier(node_text(n, source)));
348 if export_name.is_none() {
349 continue;
350 }
351 let alias = spec
352 .child_by_field_name("alias")
353 .map(|n| clean_identifier(node_text(n, source)));
354
355 added += 1;
356 rows.push(ImportRow {
357 file_path: file_path.to_string(),
358 line_number,
359 module: module.clone(),
360 name: export_name,
361 alias,
362 kind: "export".to_string(),
363 is_default: false,
364 is_wildcard: false,
365 });
366 }
367 }
368 "namespace_export" => {
369 if let Some(alias_node) = named_children(child)
370 .into_iter()
371 .find(|n| n.kind() == "identifier" || n.kind() == "string")
372 {
373 added += 1;
374 rows.push(ImportRow {
375 file_path: file_path.to_string(),
376 line_number,
377 module: module.clone(),
378 name: Some("*".to_string()),
379 alias: Some(clean_identifier(node_text(alias_node, source))),
380 kind: "export".to_string(),

Callers 1

extract_ts_like_importsFunction · 0.85

Calls 6

string_literal_valueFunction · 0.85
named_childrenFunction · 0.85
clean_identifierFunction · 0.85
is_emptyMethod · 0.80
line_for_byteMethod · 0.80
node_textFunction · 0.70

Tested by

no test coverage detected