tangled
alpha
login
or
join now
vmx-atproto-dev.bsky.social
/
mlf
forked from
stavola.xyz/mlf
0
fork
atom
A human-friendly DSL for ATProto Lexicons
0
fork
atom
overview
issues
pulls
pipelines
Fix import reference codegen
stavola.xyz
5 months ago
011ef6dc
7b037dd2
+29
-6
1 changed file
expand all
collapse all
unified
split
mlf-codegen
src
lib.rs
+29
-6
mlf-codegen/src/lib.rs
···
622
622
})
623
623
}
624
624
} else if path.segments.len() == 1 {
625
625
-
// Couldn't resolve namespace - fall back to heuristic
626
626
-
// Single segment likely means local reference
625
625
+
// Couldn't resolve namespace - check if it's an imported type
627
626
let name = &path.segments[0].name;
628
628
-
json!({
629
629
-
"type": "ref",
630
630
-
"ref": format!("#{}", name)
631
631
-
})
627
627
+
let imports = workspace.get_imports(current_namespace);
628
628
+
629
629
+
// Look for this name in imports
630
630
+
if let Some((_local_name, original_path)) = imports.iter().find(|(local, _)| local == name) {
631
631
+
// Build the full namespace#type reference from the import path
632
632
+
// original_path is like ["com", "atproto", "label", "defs", "label"]
633
633
+
// We want "com.atproto.label.defs#label"
634
634
+
if original_path.len() > 1 {
635
635
+
let namespace = original_path[..original_path.len() - 1].join(".");
636
636
+
let type_name = original_path.last().unwrap();
637
637
+
json!({
638
638
+
"type": "ref",
639
639
+
"ref": format!("{}#{}", namespace, type_name)
640
640
+
})
641
641
+
} else {
642
642
+
// Fallback: single-segment import (shouldn't happen but handle it)
643
643
+
json!({
644
644
+
"type": "ref",
645
645
+
"ref": format!("#{}", name)
646
646
+
})
647
647
+
}
648
648
+
} else {
649
649
+
// Not an import - assume local reference
650
650
+
json!({
651
651
+
"type": "ref",
652
652
+
"ref": format!("#{}", name)
653
653
+
})
654
654
+
}
632
655
} else {
633
656
// Multi-segment path ref - use as-is
634
657
let namespace = path.segments[..path.segments.len()-1]