I was playing around with IntelliJ live templates and I work every day with Instancio library https://www.instancio.org/
One of the things that are a bit verbose is writing for instance:
List<String> varName = Instancio.createList(String.class);
But at the end I also create Lists for any kind of type...
My objective was to create a live template so that when I write for instance Animal.ilist
it replaces that by
List<Animal> varName = Instancio.createList(Animal.class);
The only thing that I have achieved so far is
List<> varname = Instancio.createList(.class);
but I could not make it work for type.ilist
I am adding the answer here so it has more visibility:
I checked the postfix completion which can be found on IntelliJ 2023.2 version under
Settings -> Editor -> General -> PostFix Completion
I thought I could create a new group but I ended up adding it under Java:
Since $EXPR$ contains my class type I added the $EXPR$ to the result parts of my template where it was needed.
Note: the $END$ which sets the cursor to that position after the live template is triggered this lets you set a variable name without needing to position yourself.
Here you can see how to use it: