aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md11
-rw-r--r--mingling_cli/src/diagnostic.rs2
-rw-r--r--mingling_core/src/renderer/render_result.rs2
-rw-r--r--mingling_pathf/src/pattern_analyzer.rs1
-rw-r--r--mingling_pathf/src/patterns.rs2
-rw-r--r--mingling_pathf/test/src/lib.rs4
6 files changed, 16 insertions, 6 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5104a88..93b64a6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -95,6 +95,17 @@ None
- If the custom completion is `Suggest::FileCompletion`, the default completion is used instead (since `FileCompletion` cannot be meaningfully merged with subcommand suggestions).
- Concrete entry completions and default subcommand suggestions coexist — e.g., `thanks <tab>` now suggests both the leaf nodes (`bob`, `alice`) and the `thanks` entry's own completion.
+7. **[`core:render`]** Fixed the `RenderResult::eprintln` method to actually write to stderr. Previously, this method shamefully used `println!` (which writes to stdout) when `immediate_output` was enabled, rather than `eprintln!` (which writes to stderr). Yes, you read that right — a method literally named `eprintln` was printing to stdout. Talk about a identity crisis. The output has been corrected to use `eprintln!`, ensuring that error-level render output is properly separated from standard output streams. Whoever wrote that deserves a wet noodle slap — the entire point of an `e`-prefixed method is that it goes to standard _error_, not standard _out_. At least the bug is dead now, and we can all sleep a little easier knowing "error" output goes where error output belongs.
+
+8. **[`pathf`]** Removed the `BasicStructPattern` from the pathf pattern analyzer. This pattern previously matched arbitrary structs (in the `BasicStruct` sense) and would attempt to treat plain structs as pathf-analyzable items. However, `BasicStructPattern` produced no meaningful analysis — it matched plain structs that weren't associated with any Mingling macro (like `#[chain]`, `#[group]`, etc.), so removing it eliminates irrelevant `AnalyzeItem` entries and reduces noise in the generated `type_using.rs`.
+
+ Specifically:
+ - Removed `analyzer.add_pattern(BasicStructPattern)` from `init_with_config` in `pattern_analyzer.rs`.
+ - Removed the `basic_struct` module and its re-export (`pub use basic_struct::*;`) from `patterns.rs`.
+ - Updated the pathf integration test (`test_pattern_analyzer_once`) to assert that plain structs nested in submodules are **no longer** collected: `assert!(!result.contains("::directly_sub_mod::DirectlySubModStruct"))`.
+
+ Structs that are analyzed by other patterns (e.g., `GroupedDerivePattern`, `ChainPattern`, etc.) continue to work exactly as before — only the standalone "bare struct with no macro association" detection has been removed.
+
#### Optimizations:
1. **[`pathf`]** Added `is_module` field to `AnalyzeItem` and a new constructor `AnalyzeItem::local_module(module, item_name)` which sets `is_module: true`. The `type_mapping_builder` now tracks whether an item is a module: when generating `type_using.rs`, module items produce `use path::to::module::*;` (glob import) instead of the standard `use path::to::TypeName;` direct import. Non-module items continue to use direct imports as before. The internal data structure changed from `Vec<(String, String)>` to `Vec<(String, String, bool)>` to carry the `is_module` flag through the pipeline.
diff --git a/mingling_cli/src/diagnostic.rs b/mingling_cli/src/diagnostic.rs
index 527e879..807cdf3 100644
--- a/mingling_cli/src/diagnostic.rs
+++ b/mingling_cli/src/diagnostic.rs
@@ -26,7 +26,7 @@ fn cargo_level_to_annotate(
}
}
-/// 把 1-based char offset 转成 0-based byte offset
+/// Convert 1-based char offset to 0-based byte offset
fn char_offset_to_byte_offset(s: &str, char_offset: usize) -> usize {
s.char_indices()
.nth(char_offset.saturating_sub(1))
diff --git a/mingling_core/src/renderer/render_result.rs b/mingling_core/src/renderer/render_result.rs
index fc3f2b1..3e63a00 100644
--- a/mingling_core/src/renderer/render_result.rs
+++ b/mingling_core/src/renderer/render_result.rs
@@ -350,7 +350,7 @@ impl RenderResult {
pub fn eprintln(&mut self, text: impl Into<String>) {
let text = text.into();
if self.immediate_output {
- println!("{}", text)
+ eprintln!("{}", text)
}
self.append_line_to_buffer(text, Stderr);
}
diff --git a/mingling_pathf/src/pattern_analyzer.rs b/mingling_pathf/src/pattern_analyzer.rs
index 4675dd1..1fc0cbe 100644
--- a/mingling_pathf/src/pattern_analyzer.rs
+++ b/mingling_pathf/src/pattern_analyzer.rs
@@ -28,7 +28,6 @@ pub fn init() -> PatternAnalyzer {
/// to inject feature-dependent settings (e.g., `dispatch_tree`).
pub fn init_with_config(config: PathfinderConfig) -> PatternAnalyzer {
let mut analyzer = PatternAnalyzer::new();
- analyzer.add_pattern(BasicStructPattern);
analyzer.add_pattern(PackPattern);
analyzer.add_pattern(GroupPattern);
analyzer.add_pattern(GroupedDerivePattern);
diff --git a/mingling_pathf/src/patterns.rs b/mingling_pathf/src/patterns.rs
index fcc50c3..29d757b 100644
--- a/mingling_pathf/src/patterns.rs
+++ b/mingling_pathf/src/patterns.rs
@@ -1,6 +1,5 @@
//! Mingling path matching patterns for command routing and field mapping.
-pub use basic_struct::*;
pub use chain::*;
pub use command::*;
pub use completion::*;
@@ -13,7 +12,6 @@ pub use metadata::*;
pub use pack::*;
pub use renderer::*;
-mod basic_struct;
mod chain;
mod command;
mod completion;
diff --git a/mingling_pathf/test/src/lib.rs b/mingling_pathf/test/src/lib.rs
index 8b13e52..b543a15 100644
--- a/mingling_pathf/test/src/lib.rs
+++ b/mingling_pathf/test/src/lib.rs
@@ -58,7 +58,9 @@ fn test_pattern_analyzer_once() {
let result = analyzer
.analyze_file(dir.join("src/has_sub_mod.rs"))
.unwrap();
- assert!(result.contains("::directly_sub_mod::DirectlySubModStruct"));
+
+ // NO, basic_struct is disabled.
+ assert!(!result.contains("::directly_sub_mod::DirectlySubModStruct"));
}
#[test]