# Code templates

This page lets you configure the format of newly generated code and comments.

## Code and Comments

The code and comment page contains code templates that are used by actions that generate code. Templates contain variables that are substituted when the template is applied. Some variables are available in all templates, some are specific to templates.

Action | Description
--- | ---
Edit... | Opens a dialog to edit the currently selected code template.
Import... | Imports code templates from the file system.
Export... | Exports all selected code templates to the file system.
Export All... | Exports all code templates to the file system.

### Comment templates

Comment templates can contain the variable ${tags} that will be substituted by the standard Javadoc tags (@param, @return..) for the commented element. The 'Overriding method' comment can additionally contain the template ${see_to_overridden}

- Getter comment: Template that specifies the comment for a getter method
- Setter comment: Template that specifies the comment for a setter method
- Constructor comment: Template that specifies the comment for new constructors
- File comment: Template that specifies the header comment for newly created files. Note that this template can be referenced in the 'New Java File' template
- Type comment: Template that specifies the comment for new types. Note that this template can be referenced in the 'New Java File' template
- Field comment: Template that specifies the comment for new fields. Note that this template can be referenced in the 'New Java File' template
- Method comment: Template that specifies the comment for new methods that do not override an method in a base class
- Overriding method comment: Template that specifies the comment for new methods that override an method in a base class. By default the comment is defined as a non-Javadoc comment (Javadoc will replace this comment with the comment of the overridden method). You can change this to a real Javadoc comment if you want

### New Java files template

The 'New Java files' template is used by the New Type wizards when a new Java file is created. The template can specify where comments are added. Note that the template can contain the variable ${typecomment} that will be substituted by the evaluation of the type comment template.

### Catch block body template

The 'Catch block body' template is used when a catch block body is created. It can use the variables ${exception_type} and ${exception_var}.

### Method body template

The 'Method body' templates are used when new method with a body is created that still needs some code to complete its functionality. It contains the variable ${body_statement} that resolves to a return statement or/and a super-call.

### Constructor body template

The 'Constructor body' templates are used when new method or constructor with body is created. It contains the variable ${body_statement} that resolves a super call.

### Getter body template

The 'Getter body' templates are used when new getter method is created . It contains the variable ${body_statement} that resolves to the appropriate return statement.

### Setter body template

The 'Setter body' templates are used when new setter method is created . It contains the variable ${body_statement} that resolves to the appropriate assignment statement.

## Code Template dialog

The following fields and buttons appear in the dialog:

Action | Description
--- | ---
Description | A description of the template
Pattern | The template pattern.
Insert Variables... | Displays a list of pre-defined template specific variables.

Generating getters and setters

Source actions
Java editor
Java editor preferences
Templates preferences