-
Notifications
You must be signed in to change notification settings - Fork 30
fix: add import references when needed #1281
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
fix: add import references when needed #1281
Conversation
} else { | ||
"$instant.fromEpochSeconds(${node.value}, 0)" | ||
builder.addReferences(RuntimeTypes.Core.Instant) |
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.
Question: Is this needed here? It's already added on top
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.
Yeah, let me remove it.
return if (node.isFloatingPointNumber) { | ||
val fromEpochMilliseconds = RuntimeTypes.Core.fromEpochMilliseconds | ||
builder.addReferences(RuntimeTypes.Core.fromEpochMilliseconds) |
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.
Question: Can you avoid adding this reference and just use Instant
? How you do for fromEpochSeconds
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.
Not sure how, can you please add a suggestion instead?
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.
Something like this:
private fun getDefaultValueForTimestamp(builder: Symbol.Builder, node: NumberNode): String {
builder.addReferences(RuntimeTypes.Core.Instant)
return if (node.isFloatingPointNumber) {
val value = node.value as Double
val ms = round(value * 1e3).toLong()
"Instant.fromEpochMilliseconds($ms)"
Basically removing builder.addReferences(RuntimeTypes.Core.fromEpochMilliseconds)
Issue #1287
#1287
Description of changes
This change imports the symbol references to add them to the resulting Kotlin file. Without this the codegen for protocol tests with the latest Smithy model complains about missing symbols such as
decodeBase64
fromEpochMilliseconds
Some of the references were added but not imported. Some others needed being added and imported.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.