diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-07-21 06:03:24 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-07-21 06:03:24 +0800 |
| commit | d3abdd53e0cc86cb41c0793ce99dbb21b89a4361 (patch) | |
| tree | e6d6eb1b674185d6a906a7940226a06f3b4cf50a /mingling_pathf/src/pattern_analyzer.rs | |
| parent | 700c049f64b66f424cda5da3021dfce4462655ca (diff) | |
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.
Diffstat (limited to 'mingling_pathf/src/pattern_analyzer.rs')
| -rw-r--r-- | mingling_pathf/src/pattern_analyzer.rs | 22 |
1 files changed, 22 insertions, 0 deletions
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 |
