extractImport via the c/cpp extractImport hook: `#include ` / `#include "local.h"`. A hook miss (`#include MACRO`) extracts nothing.
(&mut self, node: Node<'t>)
| 1637 | /// extractImport via the c/cpp extractImport hook: `#include <sys.h>` / |
| 1638 | /// `#include "local.h"`. A hook miss (`#include MACRO`) extracts nothing. |
| 1639 | fn extract_import(&mut self, node: Node<'t>) { |
| 1640 | let import_text = self.text(node).trim().to_string(); |
| 1641 | let module_name: Option<String> = |
| 1642 | if let Some(sys) = self.find_child_by_kind(node, "system_lib_string") { |
| 1643 | let t = self.text(sys); |
| 1644 | let t = t.strip_prefix('<').unwrap_or(t); |
| 1645 | let t = t.strip_suffix('>').unwrap_or(t); |
| 1646 | Some(t.to_string()) |
| 1647 | } else if let Some(lit) = self.find_child_by_kind(node, "string_literal") { |
| 1648 | self.find_child_by_kind(lit, "string_content").map(|sc| self.text(sc).to_string()) |
| 1649 | } else { |
| 1650 | None |
| 1651 | }; |
| 1652 | let Some(module_name) = module_name else { return }; |
| 1653 | self.create_node( |
| 1654 | "import", |
| 1655 | &module_name, |
| 1656 | node, |
| 1657 | Extra { signature: Some(import_text), ..Extra::default() }, |
| 1658 | ); |
| 1659 | if !module_name.is_empty() { |
| 1660 | let parent = self.top_row(); |
| 1661 | self.push_ref_at(parent, &module_name, edge_kind_index("imports").unwrap(), node); |
| 1662 | } |
| 1663 | } |
| 1664 | |
| 1665 | // --- calls / instantiation ---------------------------------------------- |
| 1666 |
no test coverage detected