mirror of
https://github.com/ModernRelay/omnigraph.git
synced 2026-06-21 02:28:07 +02:00
feat(compiler): @embed model kwarg in grammar/AST/parser (RFC-012 Phase 3)
Annotations gain optional comma-separated key=value kwargs. Annotation keeps value (existing consumers unchanged) and adds kwargs: BTreeMap with serde(default, skip_serializing_if) so empty kwargs are omitted and existing schemas' IR JSON/hash stay byte-identical. The parser rejects any @embed kwarg other than model. render_annotations shows kwargs. 3 new parser tests.
This commit is contained in:
parent
30377c453b
commit
74476f7f51
6 changed files with 120 additions and 9 deletions
|
|
@ -696,9 +696,19 @@ pub(crate) fn render_constraint(constraint: &omnigraph_compiler::schema::ast::Co
|
|||
pub(crate) fn render_annotations(annotations: &[omnigraph_compiler::schema::ast::Annotation]) -> String {
|
||||
annotations
|
||||
.iter()
|
||||
.map(|annotation| match &annotation.value {
|
||||
Some(value) => format!("@{}({})", annotation.name, value),
|
||||
None => format!("@{}", annotation.name),
|
||||
.map(|annotation| {
|
||||
let mut args: Vec<String> = Vec::new();
|
||||
if let Some(value) = &annotation.value {
|
||||
args.push(value.clone());
|
||||
}
|
||||
for (key, val) in &annotation.kwargs {
|
||||
args.push(format!("{}={}", key, val));
|
||||
}
|
||||
if args.is_empty() {
|
||||
format!("@{}", annotation.name)
|
||||
} else {
|
||||
format!("@{}({})", annotation.name, args.join(", "))
|
||||
}
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
.join(", ")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue