From 1ce8480e7ae461a11b6709fd2ac21eff7f7d46e2 Mon Sep 17 00:00:00 2001 From: Amit Upadhyay Date: Mon, 2 Dec 2024 18:51:45 +0530 Subject: [PATCH] wip caption resolution --- v0.5/fastn-section/src/debug.rs | 1 + v0.5/fastn-section/src/error.rs | 1 + .../src/resolver/arguments.rs | 25 ++++++++++++++----- v0.5/fastn-unresolved/src/resolver/symbol.rs | 6 ++--- 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/v0.5/fastn-section/src/debug.rs b/v0.5/fastn-section/src/debug.rs index b3c1c7886..4e8da2b73 100644 --- a/v0.5/fastn-section/src/debug.rs +++ b/v0.5/fastn-section/src/debug.rs @@ -141,6 +141,7 @@ fn error(e: &fastn_section::Error, _s: Option) -> serde_jso fastn_section::Error::ComponentIsNotAFunction => "component_is_not_a_function", fastn_section::Error::SymbolNotFound => "symbol_not_found", fastn_section::Error::InvalidIdentifier => "invalid_identifier", + fastn_section::Error::UnexpectedCaption => "unexpected_caption", }; serde_json::json!({ "error": v}) diff --git a/v0.5/fastn-section/src/error.rs b/v0.5/fastn-section/src/error.rs index 673e5952e..fb4c0bbe5 100644 --- a/v0.5/fastn-section/src/error.rs +++ b/v0.5/fastn-section/src/error.rs @@ -25,6 +25,7 @@ pub enum Error { ComponentIsNotAFunction, SymbolNotFound, InvalidIdentifier, + UnexpectedCaption, // SectionNotFound(&'a str), // MoreThanOneCaption, // ParseError, diff --git a/v0.5/fastn-unresolved/src/resolver/arguments.rs b/v0.5/fastn-unresolved/src/resolver/arguments.rs index 6af4d9c1f..b533e93ec 100644 --- a/v0.5/fastn-unresolved/src/resolver/arguments.rs +++ b/v0.5/fastn-unresolved/src/resolver/arguments.rs @@ -1,11 +1,10 @@ #[allow(clippy::too_many_arguments)] pub fn arguments( - _arguments: &[fastn_resolved::Argument], - _caption: &mut fastn_unresolved::UR, ()>, - _properties: &mut [fastn_unresolved::UR< - fastn_unresolved::Property, - fastn_resolved::Property, - >], + arguments: &[fastn_resolved::Argument], + caption: &mut fastn_unresolved::UR, ()>, + _properties: &mut Vec< + fastn_unresolved::UR, + >, _body: &mut fastn_unresolved::UR, ()>, _children: &[fastn_unresolved::UR< fastn_unresolved::ComponentInvocation, @@ -16,4 +15,18 @@ pub fn arguments( _arena: &mut fastn_unresolved::Arena, _output: &mut fastn_unresolved::resolver::Output, ) { + if let fastn_unresolved::UR::UnResolved(None) = caption { + *caption = fastn_unresolved::UR::Resolved(()) + } + if let fastn_unresolved::UR::UnResolved(Some(_v)) = caption { + // see if any of the arguments are of type caption. + // assume there is only one such argument, because otherwise arguments would have failed + // to resolve + match arguments.iter().find(|v| v.is_caption()) { + Some(_v) => todo!(), + None => { + *caption = fastn_unresolved::UR::Invalid(fastn_section::Error::UnexpectedCaption) + } + } + } } diff --git a/v0.5/fastn-unresolved/src/resolver/symbol.rs b/v0.5/fastn-unresolved/src/resolver/symbol.rs index 931ab0932..45cd8e0bb 100644 --- a/v0.5/fastn-unresolved/src/resolver/symbol.rs +++ b/v0.5/fastn-unresolved/src/resolver/symbol.rs @@ -71,9 +71,9 @@ pub fn symbol( todo!() } None => { - // there are two case where this is valid. - // a, if the module was defined in the current module using the `-- module foo:` - // syntax, which we currently do not support + // there are two cases where this is valid. + // a, if the module was defined in the current module using the future + // `-- module foo: ` syntax. // b, this is a foo.bar case, where foo is the name of component, and we have // to look for bar in the arguments. //