Coding assistance in Java
In Smart Mode, JetBrains Fleet provides coding assistance features for your Java projects. They help you avoid mistakes and write code in an efficient manner.
Code completion
As you type, JetBrains Fleet suggests completion options. The suggestions are based on a number of factors, such as the available code intelligence services, project model, surrounding code, and the visibility of symbols.
![Code completion popup Code completion popup](https://resources.jetbrains.com/help/img/fleet/1.45/fleet-java-completion.png)
Completion suggestions will appear automatically as you type, but you can also invoke them explicitly by pressing ⌃ Space.
When you use code completion over existing code items, you can either insert the selected completion suggestion before the existing item by pressing Enter or replace the existing identifier with the selected suggestion by pressing Tab.
Code actions
JetBrains Fleet constantly analyzes your code and suggests actions that you might want to perform in the current context. The suggested actions range from correcting errors to refactoring the code at the caret.
![A popup with code actions A popup with code actions](https://resources.jetbrains.com/help/img/fleet/1.45/fleet-java-context-actions.png)
To see, which actions are available at the caret, press ⌥ ⏎. After you have selected the required action, you can apply it right away or preview the result with ⌘ P.
![Code actions preview Code actions preview](https://resources.jetbrains.com/help/img/fleet/1.45/fleet-java-code-actions-preview.png)
Apply a primary quick-fix
Open the Problems popup, which is in the upper-right corner of the window.
Click the issue that you want to fix from the list of problems.
While the issue is selected, press ⌥ ⇧ ⏎. Alternatively, you can click the link with the suggested quick-fix.
![apply_main_quick_fix apply_main_quick_fix](https://resources.jetbrains.com/help/img/fleet/1.45/fleet_java_apply_main_quick_fix.png)
Type info
Whenever you are not sure what type you are currently working with, you can look it up by pressing ⌘ ⇧ T. JetBrains Fleet will display the static type information for the symbol or expression at the caret.
![A popup with type information A popup with type information](https://resources.jetbrains.com/help/img/fleet/1.45/fleet-java-type-info.png)
Parameter info
If you are using a method that has numerous overloads, or just want to look up the required parameters, use ⌘ I.
![A popup with parameter information A popup with parameter information](https://resources.jetbrains.com/help/img/fleet/1.45/fleet-java-parameter-info.png)
Live templates
Use live templates to insert common constructs into your code, such as loops, conditions, declarations, or print statements.
![Live templates expanding into code constructs in the editor](https://resources.jetbrains.com/help/img/fleet/1.45/fleet-live-templates-java.png)
To expand a code snippet, type the corresponding template abbreviation and press ⇥. Keep pressing ⇥ to jump from one variable in the template to the next one. Press ⇧ ⇥ to move to the previous variable.
For all live templates, refer to the list of live templates.
Code generation
Use code completion to override superclass members , generate accessor methods, equals()
, hashcode()
, and so on.
![Generating a getter for the number field by typing gn and using the code completion suggestion Generating a getter for the number field by typing gn and using the code completion suggestion](https://resources.jetbrains.com/help/img/fleet/1.45/fleet-java-generate.png)
For example, if you want to generate a getter for a field called number
, type gn
and pick getNumber()
from the suggestions.