Code Snippets

Studio provides code snippets to improve the developer experience. The Code Snippets tool window is available on the right side of the IDE when a Java or Kotlin file is opened in the editor.

snippet window

You can just drag the necessary snippet from the palette to your code. Snippets are context-dependent and may request parameters from the developer.

In the example below, the Get localized message code snippet is dragged to the code, and the dialog requesting key message appeared.

snippet example

The result of adding the code snippet will be the following:

snippet example result

When you use code snippets that load data by query, the JPQL designer is automatically opened. The JPQL designer allows you to define JPQL queries for loading entities and scalar values from the database.

This feature requires a RAD or Enterprise subscription. If you don’t have the subscription, see how to get the trial version.

In the example below, the JPQL designer is appeared after dragging the Load list of entities by query code snippet.

snippet query

In the result, the following code will be added:

snippet query result

All code snippet templates are located in jmix-code-snippets.xml files inside the relevant framework modules. You can define your own snippets on the project or an add-on level: just create a jmix-code-snippets.xml file in the project’s resources using an example from the framework.