-
Notifications
You must be signed in to change notification settings - Fork 74
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
Debug string for WidgetValue #1971
Conversation
|
||
override fun toDebugString(): String { | ||
val debugString = """ | ||
|ButtonValue( |
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.
Do you think we should keep the "Value` suffix in this rendering? It's useful when referring to it in code, but I think in this rendering we might just want to use the widget name only.
val childrenDebugString = childrenLists.joinToString(prefix = " {\n", postfix = "\n}", separator | ||
= "\n") { | ||
it.toDebugString().prependIndent(" ") | ||
} |
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'm having trouble picturing how a multi-children widget renders. It looks like maybe all of the children are put into a single set of curly braces? Meaning you wouldn't be able to differentiate between them.
You might consider making widgets with multiple children render them more like properties.
TestRowValue { // Single children, renders with trailing lambda-like syntax
MultiChildrenValue(
front = {
Button(..)
Button(..)
}
back = {
Text(..)
Text(..)
}
}
of course we could render all nodes like this, but it introduces an additional layer of nesting for the single-children case which is a bit annoying.
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.
Yep, currently they would all be in one set of braces. Will try to set it up like above 👍
.addCode( | ||
buildCodeBlock { |
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.
Instead of calling .addCode
and then buildCodeBlock
and then things like addStatement
, you can call apply
which will give you the ability to do if
/else
and call addStatement
and the like
Adds a "pretty printed" string to WidgetValue. This makes tests easier to debug
CHANGELOG.md
's "Unreleased" section has been updated, if applicable.