Why override val recipe: Recipe get() ={ } called twice?

Answered

I am trying to build plugin for genrate template for android studio  but I don't knock why the 

override val recipe: Recipe
get() ={}

part called twice. For that reason this file genarating same code twice.
I also try to put breakpoint inside get() . Its triggered twice

Here is full code

<extensions defaultExtensionNs="com.android">
<tools.idea.wizard.template.wizardTemplateProvider
implementation="com.example.demo1.recipes.CustomWizardTemplateProvider"/>

</extensions>
class CustomWizardTemplateProvider: WizardTemplateProvider() {
override fun getTemplates(): List<Template> {
return listOf(CustomScreenTemplate)
}
}
object CustomScreenTemplate: Template {

private val packageName = defaultPackageNameParameter
private val activityClass = stringParameter {
default="Home"
name= "Screen Name"
help="Add compose Screen"
constraints= listOf(Constraint.UNIQUE)

}

private val includeNavigation = booleanParameter {
name="Include Navigation File"
default =true
help= "If true navigation entry will be done"
}

override val category: Category
get() = Category.Compose
override val constraints: Collection<TemplateConstraint>
get() = emptyList()
override val description: String
get() = "Setup Compose Screen"
override val documentationUrl: String
get() = "fb.me/masumfromjessore"
override val formFactor: FormFactor
get() = FormFactor.Mobile
override val minSdk: Int
get() = 23
override val name: String
get() = "Compose Screen"
override val recipe: Recipe
get() ={



customScreenRecipe(it as ModuleTemplateData, activityClass.value, includeNavigation = includeNavigation.value ,packageName.value)
}

override val uiContexts: Collection<WizardUiContext>
get() = listOf(WizardUiContext.MenuEntry)
override val useGenericInstrumentedTests: Boolean
get() = false
override val useGenericLocalTests: Boolean
get() = false
override val widgets: Collection<Widget<*>>
get() = listOf(
TextFieldWidget(activityClass),


)
override val parameters: Collection<Parameter<*>>
get() = super.parameters

override fun thumb(): Thumb {
return Thumb { findResource(this.javaClass, File("masum.jpg")) }
}

}
0
2 comments

This question seems like about Kotlin programming basics. It is called twice because something calls it twice. It seems unrelated to the IntelliJ Platform.

Please avoid asking this kind of question. I suggest investing some time in learning Kotlin and the IntelliJ Platform before you go further.

0

I added all code i use to call. I called it only one time.

0

Please sign in to leave a comment.