Is there a way to generate multiple files/classes with intellij code/file templates?

Intellij IdeaCode GenerationVtl

Intellij 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

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionTrevor GowingView Question on Stackoverflow
Solution 1 - Intellij IdealeeorView Answer on Stackoverflow
Solution 2 - Intellij IdeaCeH9View Answer on Stackoverflow
Solution 3 - Intellij IdeaJamolView Answer on Stackoverflow
Solution 4 - Intellij IdeaFederico TomassettiView Answer on Stackoverflow
Solution 5 - Intellij IdeaNazeeb AlookaranView Answer on Stackoverflow