Generate Multiple Classes

Is there a way (sounds far fetched maybe ) to generate specific template classes on creation of a class?  For example, if I was to create a new Flex 4 mxml component, automatically a skeleton Skin would get created (maybe of a template I define) and maybe a SkinnableContainer class?


Not far fetched at all. That functionality is built into IDEA (and has been since its early days).  What you are looking for is the "File Templates" feature. You can also use the "Live Template" feature. As stated in IDEA help on the page IntelliJ IDEA > Basic Concepts > File Templates, "File templates help generate stubs and thus start working with the files that already contain some basic initial code, rather than from scratch." By using template variables and parse directives, you can automatically include things like the package declaration, lggers, etc. To create a File Template, go into settings (ctrl+alt+S or File | Settings or the wrench icon on the main toolbar) and go to the File Templates section. IDEA comes with a number of templates built in and can serve as examples. And there is useful info in the help, or on the web help page here. The templates are then available to you in the "New" context menu. Commonly used one's show up directly in the "New" context. Others are accessed via the "From File Template..." context menu item.

"Live Templates", -- see the help page IntelliJ IDEA > Basic Concepts > Live Templates or the web help page -- are for including code snippets in already existing files.


Hi Mark thanks for your time to reply it was appreciated.  I see where your coming from and the links were spot on, I have worked with both File and Live Templates, what I am more specifically trying to find out is whether you can actually have mutliple classes generated based on File Templates when a specific template is created (excuse me if you have answered this in your reply)?  So the work flow would be as follows:

New > Custom Class (based on a File Template) > Enter name and parameters required for this new Class *including* a name for a second new class it will also create at the same time > CustomClassOne and CustomSubClassOne are then created.

I suppose a simpler way to explain it would be I want to create a Class and it creates an interface also for me with out me having to manually create both in 2 seperate tasks?

Sorry I may have over egged this ;)




To the best of my knowledge, it cannot create multiple file based classes. The closest would be creating a second or third class within the same file. (I'm not sure off hand if that is valid in ActionScript like it is in Java.)

If your ultimate goal is to create a class and an interface, you could use the File Template to create the class and then use the "Extract Interface" (Java, ActionScipt and MXML) or "Extract Superclass" (Java, ActionScript) refactorings.While it is still multiple steps, the extract interface/superclass refactorings are pretty quick and easy to use.

The "Copy " refactoing is also pretty handy and might be useful to you.

As an FYI, I'm using the IDEA 10 EAP (Early Access Program) build. In know they have added a lot of Flex refactorings in IDEA 10. So off the top of my head I do not know if the extract refactorings are available in IDEA 9 for ActionScript and/or MXML.


OK thanks man, I think I can safely assume that my question was slightly pie in the sky, but good to ask anyway.  Thanks for your help mate!  My primary reason for this would be for a custom flex skin to be created when a particular class template is utilised, may put it in as a (over presumptuous) feature request :)


The consensus is this is not possible (unless informed otherwise from IntelliJ) but could be a possible feature request.


Please sign in to leave a comment.