From d3abdd53e0cc86cb41c0793ce99dbb21b89a4361 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Tue, 21 Jul 2026 06:03:24 +0800 Subject: feat(pathf): add foreign item support with is_foreign flag Add `AnalyzeItem::foreign()` and `AnalyzeItem::local()` constructors to distinguish items resolved via `use` imports from local definitions. Update `GroupPattern` to collect use imports at file and module levels, resolving `group!(TypeName)` against them. Migrate all pattern implementations to use the new constructors, and adjust `type_mapping_builder` to skip the file's own module prefix for foreign items. --- mingling_pathf/src/pattern_analyzer.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'mingling_pathf/src/pattern_analyzer.rs') diff --git a/mingling_pathf/src/pattern_analyzer.rs b/mingling_pathf/src/pattern_analyzer.rs index 31d6918..5b25c15 100644 --- a/mingling_pathf/src/pattern_analyzer.rs +++ b/mingling_pathf/src/pattern_analyzer.rs @@ -48,6 +48,28 @@ pub struct AnalyzeItem { pub module: String, /// The name of the item itself, e.g. `"HashMap"`, `"AnalyzeResult"`, etc. pub item_name: String, + /// Whether the item is from an external crate (resolved via `use`), bypassing the file's own module path. + pub is_foreign: bool, +} + +impl AnalyzeItem { + /// Creates a local `AnalyzeItem` (not foreign, will be prefixed with the file's module path). + pub fn local(module: String, item_name: String) -> Self { + Self { + module, + item_name, + is_foreign: false, + } + } + + /// Creates a foreign `AnalyzeItem` (resolved via `use`, the `module` field is the full import path). + pub fn foreign(module: String, item_name: String) -> Self { + Self { + module, + item_name, + is_foreign: true, + } + } } /// Collection of analysis results -- cgit