Is there a way to generate multiple files/classes with intellij code/file templates?
Intellij IdeaCode GenerationVtlIntellij Idea Problem Overview
I like intellij's code/file templates, they are working really well for me for single files but it would be great to be able to create multiple files/classes at once.
I did find this question but since it has been a few years since I was hoping that things might have changed.
We are using the mvp pattern in our application so every time we want to create a new view, it requires two classes and two interfaces, which are always in the same pattern. It would be awesome if we could generate all of the infrastructure for this and link up the classes.
Any suggestions or new information would be appreciated? Maybe it is time to log a feature request with JetBrains?
Intellij Idea Solutions
Solution 1 - Intellij Idea
This feature seems to be available in ReSharper (another JetBrains
IDE). It still does not seem possible in IDEA
yet.
Solution 2 - Intellij Idea
At the moment IDE doesn't support this feature. Most popular youtrack request have 60+ votes, but it still opened(since 2012). You can use 3rd party solution, for example this plugin.
Solution 3 - Intellij Idea
It's possible (now). See below links.
https://riggaroo.co.za/custom-file-template-group-android-studiointellij/ https://medium.com/codequest/file-group-templates-in-android-studio-unofficial-guide-85dfa0a0c1ec
Solution 4 - Intellij Idea
You could easily do that using JavaParser but I am not sure how you could invoke it from the IDEA interface
Solution 5 - Intellij Idea
I think you are looking for this,
Open the desired file in the editor. On the main menu, choose Tools | Save File as Template. In the File and Code Templates dialog box that opens specify the new template name and edit the source code, if necessary.save changes and close the dialog box.