Skip to content

Commit cc7c4cd

Browse files
committed
Move addRequiredImports into SharedCodegen
1 parent def0558 commit cc7c4cd

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
@@ -559,6 +559,12 @@ abstract class SharedCodegen : DefaultCodegen(), CodegenConfig {
559559
*/
560560
protected abstract fun nullableTypeWrapper(baseType: String): String
561561

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

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

0 commit comments

Comments
 (0)