When you press the combination Alt-Insert (Ctrl-I on Mac), a menu opens with all possible code generators. The list of generators is context sensitive. It depends on the position of the caret in the code when the key combination is pressed. Depending on your position in the code, you can generate a database connection, database tables, lorum ipsum text, and several others. This section describes only the following code generators:
You can generate constructors by pressing Alt-Insert (Ctrl-I on Mac) when the caret is inside a class body, but not inside any functions contained in that body. When you select Generate... Constructor, a dialog opens llisting the fields you can initialize by the constructor. The field names are used as parameters of the constructor.
You can decide not to select any fields. In this case, the IDE generates an empty constructor, with no parameters. If the field is a class with properties, you can either select individual properties, or you can select the class, in which case all the class' properties are selected automatically.
For more information, see the .
You can generate getters and setters by pressing Alt-Insert (Ctrl-I on Mac) when the caret is inside a class body and selecting Getter, Setter, or Getters and Setters. Only the possible functions are displayed. For example, if you already have setters for the available properties, only the getter option appears.
When you select Generate... Getter/Setter/Getter and Setter, a dialog appears with the properties for which you can generate a getter or setter. The properties are displayed in a tree. If you select a parent class, you automatically select all that class' properties.
You can name a getter or setter according to either the convention getName or the convention get_name.
For more information, see the original and the post on .
You can generate overridden or implemented methods by pressing Alt-Insert (Ctrl-I on Mac) when the caret is inside a class declaration and there are multiple class members. A dialog opens showing the methods you can insert and indicating whether they are overridden or implemented.
This feature complements the "Implement all abstract methods" hint and code completion for overridden and implemented methods.
For more information, see the .