-
Notifications
You must be signed in to change notification settings - Fork 27
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 outstanding cases with importing #97
Conversation
Builds on #90 and fixes nested and same type importing
I am not sure if this test / bug is related to this PR: @Test
fun testSomeTest() {
val type =
TypeSpec.structBuilder("SomeType")
.addProperty(
PropertySpec.varBuilder(
"foundation_order",
typeName("Foundation.SortOrder")
).build()
)
.addProperty(
PropertySpec.varBuilder(
"order",
typeName("some_other_module.SortOrder")
).build()
)
.build()
val testFile = FileSpec.builder("Test", "Test")
.addImport("Foundation")
.addType(type)
.build()
val out = StringWriter()
testFile.writeTo(out)
assertThat(
out.toString(),
equalTo(
"""
import Foundation
struct SomeType {
var foundation_order: SortOrder
var order: some_other_module.SortOrder
}
""".trimIndent()
)
)
} |
Added test and reworked to include fix. This required me to rework your All tests are passing and, additionally, it caught a missing import in one of the existing tests. |
Update from Slack conversations, we identified one more test case that fails with @Test
@DisplayName("Generates all required imports with naming conflicts and always qualified")
fun testSomething() {
val type =
TypeSpec.structBuilder("SomeType")
.addProperty(
PropertySpec.varBuilder(
"foundation_order",
typeName("Foundation.SortOrder", alwaysQualify = true)
).build()
)
.addProperty(
PropertySpec.varBuilder(
"order",
typeName("some_other_module.SortOrder")
).build()
)
.build()
val testFile = FileSpec.builder("Test", "Test")
.addType(type)
.build()
val out = StringWriter()
testFile.writeTo(out)
assertThat(
out.toString(),
equalTo(
"""
import Foundation
import some_other_module
struct SomeType {
var foundation_order: Foundation.SortOrder
var order: SortOrder
}
""".trimIndent()
)
)
} |
Builds on #90 and fixes nested and same type importing