Inlay Hints

Edit page Last modified: 29 九月 2022

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 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 calls.

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

  • 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.

The IntelliJ Platform offers two extension points (EP) that plugin developers can implement to create inlay hints:

  • The com.intellij.codeInsight.parameterNameHints EP is used to provide simple text inlays for, e.g., parameter names in method and function calls.

  • The com.intellij.codeInsight.inlayProvider EP is used for more general cases where plugin developers need extended control or want to implement interactive features for inlay hints.

The main difference between both EPs is that the first one only lets you place string inlays while the second one allows for the placement of inline and block inlays with customizable representation.