How can I automatically assign a variable to a variable by type in a real template?

Using dagger, Im injecting fields a lot - so I created a live template to declare the injected variable:

@Inject
lateinit var $var$: $TYPE$

      

In Java, a similar live template will automatically populate the repository as I have given the type Repository

.

In Kotlin, however, this is not the case. But I'm sure it's possible?

+3


source to share


2 answers


I thought! Posting the screenshot, I think this explains it in the best way.



Current template variables

+4


source


I have a small variation using smart completion. The main thing that dodged me at first was to reorder the variables so that the TYPE comes before the VAR. Otherwise, the type will be empty. Spring Virtual Template Variables



0


source







All Articles