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

Function parse_ts_import_statement

crates/devsql/src/providers/imports.rs:204–246  ·  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

202}
203
204fn parse_ts_import_statement(
205 node: Node,
206 source: &str,
207 lines: &LineIndex<'_>,
208 file_path: &str,
209 rows: &mut Vec<ImportRow>,
210) {
211 let line_number = lines.line_for_byte(node.start_byte()) as i64;
212 let module = node
213 .child_by_field_name("source")
214 .map(|n| string_literal_value(n, source))
215 .unwrap_or_default();
216
217 let mut entries = 0usize;
218 for child in named_children(node) {
219 match child.kind() {
220 "import_clause" => {
221 entries += parse_ts_import_clause(
222 child,
223 source,
224 file_path,
225 line_number,
226 &module,
227 rows,
228 );
229 }
230 _ => {}
231 }
232 }
233
234 if entries == 0 {
235 rows.push(ImportRow {
236 file_path: file_path.to_string(),
237 line_number,
238 module: module.clone(),
239 name: None,
240 alias: None,
241 kind: "import".to_string(),
242 is_default: false,
243 is_wildcard: false,
244 });
245 }
246}
247
248fn parse_ts_import_clause(
249 clause: Node,

Callers 1

extract_ts_like_importsFunction · 0.85

Calls 4

string_literal_valueFunction · 0.85
named_childrenFunction · 0.85
parse_ts_import_clauseFunction · 0.85
line_for_byteMethod · 0.80

Tested by

no test coverage detected