(&mut self, node: Node<'t>)
| 861 | // --- extractImport (:3170; hook dart.ts:261-304) ---------------------- |
| 862 | |
| 863 | fn extract_import(&mut self, node: Node<'t>) { |
| 864 | let find_child = |parent: Node<'t>, kind: &str| -> Option<Node<'t>> { |
| 865 | let mut cursor = parent.walk(); |
| 866 | let found = parent.named_children(&mut cursor).find(|c| c.kind() == kind); |
| 867 | found |
| 868 | }; |
| 869 | let uri_of = |spec: Node<'t>| -> Option<Node<'t>> { |
| 870 | let configurable = find_child(spec, "configurable_uri")?; |
| 871 | let uri = find_child(configurable, "uri")?; |
| 872 | find_child(uri, "string_literal") |
| 873 | }; |
| 874 | let mut module: Option<String> = None; |
| 875 | if let Some(li) = find_child(node, "library_import") { |
| 876 | if let Some(spec) = find_child(li, "import_specification") { |
| 877 | if let Some(sl) = uri_of(spec) { |
| 878 | module = Some(self.text(sl).replace(['\'', '"'], "")); |
| 879 | } |
| 880 | } |
| 881 | } |
| 882 | if module.is_none() { |
| 883 | if let Some(le) = find_child(node, "library_export") { |
| 884 | if let Some(sl) = uri_of(le) { |
| 885 | module = Some(self.text(sl).replace(['\'', '"'], "")); |
| 886 | } |
| 887 | } |
| 888 | } |
| 889 | // Deferred imports (bare `uri`, no configurable_uri) → hook null → |
| 890 | // nothing at all (invisible). |
| 891 | let Some(module) = module.filter(|m| !m.is_empty()) else { return }; |
| 892 | let signature = self.text(node).trim().to_string(); |
| 893 | let created = self.create_node( |
| 894 | "import", |
| 895 | &module, |
| 896 | node, |
| 897 | Extra { signature: Some(signature), ..Default::default() }, |
| 898 | ); |
| 899 | if created.is_some() && !self.stack.is_empty() { |
| 900 | let parent_row = self.top_row(); |
| 901 | self.push_ref_at(parent_row, &module, "imports", node); |
| 902 | } |
| 903 | } |
| 904 | |
| 905 | // --- extractInstantiation (:4610, generic tail) ----------------------- |
| 906 |
no test coverage detected