-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add multiple cases to NonEmptyString support #375
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thank you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't find anything wrong with it. Would appreciate comments explaining the more dense parts. Other thank that, looks great, thank you!
@@ -130,6 +130,27 @@ trait BesomSyntax: | |||
res <- ctx.readOrRegisterResource[A, EmptyArgs](companion.typeToken, name, EmptyArgs(), CustomResourceOptions(importId = id)) | |||
yield res | |||
|
|||
extension (s: String) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love those converters, very useful!
import besom.util.interpolator.* | ||
inline def fromStringOutput(inline s: Output[String]): Output[NonEmptyString] = ${ fromStringOutputImpl('s) } | ||
|
||
private def fromStringOutputImpl(expr: Expr[Output[String]])(using quotes: Quotes): Expr[Output[NonEmptyString]] = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wow, I didn't know you can poke inside interpolators with macros like that, impressive
@@ -39,8 +64,34 @@ object NonEmptyString: | |||
private def fromImpl(expr: Expr[String])(using quotes: Quotes): Expr[NonEmptyString] = | |||
import quotes.reflect.* | |||
|
|||
// kudos to @Kordyjan for most of this implementation | |||
def downTheRabbitHole(tree: Term): Either[Term, String] = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is quite dense, I would appreciate adding some comments to guide the reader through this code, esp. for people not fluent in macros
I understand that we are recursively examining the AST and trying to figure out all cases where it can be proven the result string will be not empty, but I'm sure I'm missing some important details.
In the interest of maintenance, adding comments would be greatly appreciated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, no problem. Give me a minute.
Ah. One more thing, please update the Changelog :) |
…till necessary for cross-compile unit inference?
faa74d9
to
8e1686b
Compare
done! |
No description provided.