3

Using dagger, Im injecting fields a lot - so I created a live template for declaring an injected variable:

@Inject
lateinit var $var$: $TYPE$

In Java, a similar live template would automatically fill in repository as I specified the type to be Repository.

In Kotlin, however - it does not. But Im sure its possible?

zoltish
  • 2,122
  • 19
  • 37

2 Answers2

4

Figured it out! Posting a screenshot as I think that explains it the best.

Live template variables

zoltish
  • 2,122
  • 19
  • 37
1

I have a slight variation on this that uses smart completion. The key thing that evaded me at first was making sure you re-order the variables so the TYPE is before the VAR. Otherwise the type will be empty. Spring Live Template Variables

Nate Good
  • 439
  • 4
  • 11