# Inlay Hints

> For the complete documentation index, see [llms.txt](https://plugins.jetbrains.com/docs/intellij/llms.txt).

> **TL;DR**
> Product Help: [Inlay Hints](https://www.jetbrains.com/help/idea/inlay-hints.html)

Inlay hints render small pieces of information directly into the editor and give developers additional code insight without disturbing the workflow. A well-known example is parameter hints that usually display the name of the function parameters as given in its declaration. They are closely related to [Parameter Info](parameter-info.html) which shows parameter types for all possible overloads of a function but opens as a popup overlaying the code.

Inlay hints are flexible and have a wide range of applications in the IntelliJ Platform. For instance, the following are well-known examples where inlay hints are used:

* Java uses inlays to display type annotations in Java chained method calls.

* Kotlin uses inlays in range expressions to show, e.g. less-than, or less-than-or-equal signs to let developers know if intervals are inclusive or exclusive.

* In version-controlled projects, the author of the code is shown using inlay hints.

## Implementation

The main characteristic of the inlay is the way it is displayed in the editor:

* inline - inlays displayed in the code between code tokens

* block - inlays displayed above a code block

Depending on the requirements and target IntelliJ Platform version, there are several extension points to choose from, when implementing inlay hints.

This section describes the available APIs and their use cases.

> **Tip:**
> To inspect existing Inlays in the IDE, use [UI Inspector](internal-ui-inspector.html#editor). Corresponding entries from `Settings | Editor | Inlay Hints` are also available from [Inspecting Settings](internal-ui-inspector.html#inspecting-settings).

### Inlay Parameter Hints Provider

Inlay parameter hints are simple string inline inlays placed before parameter names in method and function calls. It is not possible to provide advanced presentation and behavior of inlay parameter hints.

To provide inlay parameter hints, implement [InlayParameterHintsProvider](https://github.com/JetBrains/intellij-community/tree/idea/263.7307.200/platform/lang-api/src/com/intellij/codeInsight/hints/InlayParameterHintsProvider.java) and register it in [com.intellij.codeInsight.parameterNameHints](https://jb.gg/ipe?extensions=com.intellij.codeInsight.parameterNameHints) extension point  (EP). The API documentation of `InlayParameterHintsProvider` explains in detail the rationale behind all methods.

Examples:

* [GroovyInlayParameterHintsProvider](https://github.com/JetBrains/intellij-community/tree/idea/263.7307.200/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInsight/hint/GroovyInlayParameterHintsProvider.kt) - shows parameter hints in Groovy code

* [JavaInlayParameterHintsProvider](https://github.com/JetBrains/intellij-community/tree/idea/263.7307.200/java/java-impl/src/com/intellij/codeInsight/hints/JavaInlayParameterHintsProvider.kt) - shows parameter hints in Java code

To suppress inlay parameter hints in specific places, implement [ParameterNameHintsSuppressor](https://github.com/JetBrains/intellij-community/tree/idea/263.7307.200/platform/lang-api/src/com/intellij/codeInsight/hints/ParameterNameHintsSuppressor.kt) and register it in [com.intellij.codeInsight.parameterNameHintsSuppressor](https://jb.gg/ipe?extensions=com.intellij.codeInsight.parameterNameHintsSuppressor) extension point .

### Declarative Inlay Hints Provider

Declarative inlay hints are inline textual inlays that can hold expandable list of clickable items. Please note this API has limited presentation customization possibilities due to its UI-independent design, which allows utilizing it by different frontend technologies (not only in Swing).

To provide declarative inlay hints implement declarative [InlayHintsProvider](https://github.com/JetBrains/intellij-community/tree/idea/263.7307.200/platform/lang-api/src/com/intellij/codeInsight/hints/declarative/InlayHintsProvider.kt) and register it in [com.intellij.codeInsight.declarativeInlayProvider](https://jb.gg/ipe?extensions=com.intellij.codeInsight.declarativeInlayProvider) extension point . See the API documentation for the details.

Examples:

* [JavaImplicitTypeDeclarativeInlayHintsProvider](https://github.com/JetBrains/intellij-community/tree/idea/263.7307.200/java/java-impl/src/com/intellij/codeInsight/hints/JavaImplicitTypeDeclarativeInlayHintsProvider.kt) - shows inferred type for variables declared with the `var` keyword in Java code when the inferred type may not be clear

* [JavaMethodChainsDeclarativeInlayProvider](https://github.com/JetBrains/intellij-community/tree/idea/263.7307.200/java/java-impl/src/com/intellij/codeInsight/hints/JavaMethodChainsDeclarativeInlayProvider.kt) - shows method return types in call chains in Java code

To provide a custom configuration UI, implement [InlayHintsCustomSettingsProvider](https://github.com/JetBrains/intellij-community/tree/idea/263.7307.200/platform/lang-api/src/com/intellij/codeInsight/hints/declarative/InlayHintsCustomSettingsProvider.kt) registered in [com.intellij.codeInsight.declarativeInlayProviderCustomSettingsProvider](https://jb.gg/ipe?extensions=com.intellij.codeInsight.declarativeInlayProviderCustomSettingsProvider) extension point .

Preview texts displayed for inlay hint providers under `Settings | Editor | Inlay Hints` must be located in plugin resources in `inlayProviders/$provider_id$` directory, for example, `inlayProviders/java.implicit.types`. The `$provider_id$` value must match the `providerId` attribute of [com.intellij.codeInsight.declarativeInlayProvider](https://jb.gg/ipe?extensions=com.intellij.codeInsight.declarativeInlayProvider) extension point . The preview file name must be `preview.$ext$`, where `$ext$` is a default extension of a supported file type, for example, `preview.java`. Hints displayed in the preview panel are defined with the dedicated markup:

2023.2+:

```TEXT
/*<# Displayed Hint #>*/
```

Pre-2023.2:

```TEXT
<# Displayed Hint #>
```

Examples:

* [inlayProviders/java.implicit.types/preview.java](https://github.com/JetBrains/intellij-community/tree/idea/263.7307.200/java/java-impl/resources/inlayProviders/java.implicit.types/preview.java)

* [inlayProviders/groovy.lambda.parameter.inlay.provider/preview.groovy](https://github.com/JetBrains/intellij-community/tree/idea/263.7307.200/plugins/groovy/resources/inlayProviders/groovy.lambda.parameter.inlay.provider/preview.groovy)

### Code Vision Provider

> **Note:**
> This API is still in experimental state and may be changed without preserving backward compatibility.

Code vision provider allows for providing block inlay hints for elements like class, method, field, etc. If there are multiple hints provided for a single element, all will be displayed in the same line to save vertical space.

Code vision hints can be displayed over the element, or on the right, at the end of line. It is configurable by users in `Settings | Editor | Inlay Hints | Code vision` by choosing a value in Default position for metrics combo box, or by selecting Position in specific provider entries.

There are three extension points for implementing a code vision provider:

* [DaemonBoundCodeVisionProvider](https://github.com/JetBrains/intellij-community/tree/idea/263.7307.200/platform/lang-impl/src/com/intellij/codeInsight/hints/codeVision/DaemonBoundCodeVisionProvider.kt) registered in [com.intellij.codeInsight.daemonBoundCodeVisionProvider](https://jb.gg/ipe?extensions=com.intellij.codeInsight.daemonBoundCodeVisionProvider) extension point

* [CodeVisionProvider](https://github.com/JetBrains/intellij-community/tree/idea/263.7307.200/platform/lang-impl/src/com/intellij/codeInsight/codeVision/CodeVisionProvider.kt) registered in [com.intellij.codeInsight.codeVisionProvider](https://jb.gg/ipe?extensions=com.intellij.codeInsight.codeVisionProvider) extension point

* [CodeVisionGroupSettingProvider](https://github.com/JetBrains/intellij-community/tree/idea/263.7307.200/platform/lang-impl/src/com/intellij/codeInsight/codeVision/settings/CodeVisionGroupSettingProvider.kt) registered in [com.intellij.config.codeVisionGroupSettingProvider](https://jb.gg/ipe?extensions=com.intellij.config.codeVisionGroupSettingProvider) extension point

`DaemonBoundCodeVisionProvider` API should be used in cases when code vision entries are related to PSI, so that calculated values are invalidated and recalculated on PSI changes.

`CodeVisionProvider` API should be used for cases when presented information doesn't depend on the PSI.

The `CodeVisionGroupSettingProvider` is necessary for displaying the name and description of the code vision provider in the settings. The `groupId` must match the value specified in the implementation of the `CodeVisionProvider`; if not specified, it defaults to the `id`. The `groupName` is the name shown in the code vision group, and the `description` will be visible in the right details panel.

Code vision preview is available under `Settings | Editor | Inlay Hints | Code vision`. In case if multiple preview examples in different languages are provided for an existing code vision provider, IDE will choose the most important from its point of view. For example, IntelliJ IDEA will use Java preview, PhpStorm will use PHP preview, etc.

To provide a preview example for a custom code vision provider:

1. Create a `codeVisionProviders/$model_id$/preview.$ext$` file, for example, `codeVisionProviders/vcs.code.vision/preview.java`. The `$modelId$` must match the `groupId` of `CodeVisionGroupSettingProvider` and `modelId` (see 2.).

2. Register an `com.intellij.codeInsight.codeVisionSettingsPreviewLanguage`, which specifies the preview `language` and `modelId`.

Examples:

* [KotlinScriptDefinitionCodeVisionProvider](https://github.com/JetBrains/intellij-community/tree/idea/263.7307.200/plugins/kotlin/base/scripting/scripting/src/org/jetbrains/kotlin/idea/core/script/definitions/KotlinScriptDefinitionCodeVisionProvider.kt) - shows the script definition hint. Clicking the inlay opens the script definition settings. This provider is `DaemonBoundCodeVisionProvider`.

* [VcsCodeVisionProvider](https://github.com/JetBrains/intellij-community/tree/idea/263.7307.200/platform/vcs-impl/lang/src/com/intellij/codeInsight/hints/VcsCodeVisionProvider.kt) - shows the author of a given element, e.g., class or method, based on VCS information. This provider is `CodeVisionProvider`.

### Inlay Hints Provider

Inlay hints provider allows for implementing both inline and block inlay hints with custom presentation and behavior. See the API documentation for the details.

> **Warning: Deprecation Notice**
> For implementing inline inlay hints in versions 2023.1 and newer, [Declarative Inlay Hints Provider](#declarative-inlay-hints-provider) is recommended.
>
>
>
> For implementing block inlay hints in versions 2022.1 and newer, [Code Vision Provider](#code-vision-provider) is recommended.

To provide inlay hints, implement [InlayHintsProvider](https://github.com/JetBrains/intellij-community/tree/idea/263.7307.200/platform/lang-api/src/com/intellij/codeInsight/hints/InlayHintsProvider.kt) and register it in [com.intellij.codeInsight.inlayProvider](https://jb.gg/ipe?extensions=com.intellij.codeInsight.inlayProvider) extension point . See the API documentation for the details.

Examples:

* [GroovyLocalVariableTypeHintsInlayProvider](https://github.com/JetBrains/intellij-community/tree/idea/263.7307.200/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInsight/hint/types/GroovyLocalVariableTypeHintsInlayProvider.kt) - shows local variable types in Groovy code

* [MarkdownTableInlayProvider](https://github.com/JetBrains/intellij-community/tree/idea/263.7307.200/plugins/markdown/core/src/org/intellij/plugins/markdown/editor/tables/ui/MarkdownTableInlayProvider.kt) - decorates tables in Markdown files.

### Further Tips

1. Go to `Settings | Editor | Inlay Hints` ([Product Help](https://www.jetbrains.com/help/idea/inlay-hints.html)) and check out inlays that have already been implemented.

2. To support multiple languages with a single type of inlay hints, see declarative [InlayHintsProviderFactory](https://github.com/JetBrains/intellij-community/tree/idea/263.7307.200/platform/lang-api/src/com/intellij/codeInsight/hints/declarative/InlayHintsProviderFactory.kt) (2023.1+) or [InlayHintsProviderFactory](https://github.com/JetBrains/intellij-community/tree/idea/263.7307.200/platform/lang-api/src/com/intellij/codeInsight/hints/InlayHintsProviderFactory.kt) (pre-2023.1).

3. For testing inlay hints, see [InlayHintsProviderTestCase](https://github.com/JetBrains/intellij-community/tree/idea/263.7307.200/platform/testFramework/src/com/intellij/testFramework/utils/inlays/InlayHintsProviderTestCase.kt) and [InlayParameterHintsTest](https://github.com/JetBrains/intellij-community/tree/idea/263.7307.200/platform/testFramework/src/com/intellij/testFramework/utils/inlays/InlayParameterHintsTest.kt).

