Search code examples
intellij-ideaintellij-plugin

How to set background colour for PsiJavaToken?


I want to implement an IntelliJ plugin, one feature is we allow developers select a code snippet, and then set the background color for the region. Therefore, I want to ask whether it is possible to set a background color for PsiJavaToken or for a selected region.


Solution

  • Yes, it's possible. One way to achieve this is to create a local inspection, create problem descriptors in checkFile() method and use ProblemDescriptor.setTextAttributes() to set background color.