Skip to content

Commit 7a19744

Browse files
committed
Move addRequiredImports into SharedCodegen
1 parent 54394ee commit 7a19744

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

gradle-plugin/plugin/src/main/java/com/yelp/codegen/KotlinGenerator.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ open class KotlinGenerator : SharedCodegen() {
203203
}
204204

205205
@VisibleForTesting
206-
internal fun addRequiredImports(codegenModel: CodegenModel) {
206+
override fun addRequiredImports(codegenModel: CodegenModel) {
207207
// If there are any vars, we will mark them with the @Json annotation so we have to make sure to import it
208208
if (codegenModel.allVars.isNotEmpty() || codegenModel.isEnum) {
209209
codegenModel.imports.add("com.squareup.moshi.Json")

gradle-plugin/plugin/src/main/java/com/yelp/codegen/SharedCodegen.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,12 @@ abstract class SharedCodegen : DefaultCodegen(), CodegenConfig {
562562
*/
563563
protected abstract fun nullableTypeWrapper(baseType: String): String
564564

565+
/**
566+
* Hook that allows to add the needed imports for a given [CodegenModel]
567+
* This is needed as we might be modifying models in [postProcessAllModels]
568+
*/
569+
internal abstract fun addRequiredImports(codegenModel: CodegenModel)
570+
565571
private fun defaultListType() = typeMapping["list"] ?: ""
566572

567573
private fun defaultMapType() = typeMapping["map"] ?: ""

0 commit comments

Comments
 (0)