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