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

7.2k Views Asked by At

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?

5

There are 5 best solutions below

1
On
0
On

You could easily do that using JavaParser but I am not sure how you could invoke it from the IDEA interface

0
On

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.

0
On

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.

0
On

This feature seems to be available in ReSharper (another JetBrains IDE). It still does not seem possible in IDEA yet.