How to add custom IntelliJ Language Injection to scala interpolation string?

using Scala in IntelliJ you can already do

var c = s"some ${compound * expression}" 

and have the correct syntax highlighting for ${compound * expression} . Scala allows you to define custom string interpolators, do other things

 var c = javascript"var x = [1, 2, 3]" 

Does anyone know how to tinker with custom I / O functions to highlight these custom string interpolators well? I came across things in the “File-> Settings-> Language Injections” section, but this seems really confusing, and I cannot find any existing injections that perform the magic string interpolation syntax. It is supposed to be hardcoded (since it also has good code navigation features), but I hope there will be some way to make it recognize the good something"..." syntax and highlight it well for me.

+8
string scala intellij-idea syntax-highlighting
source share
1 answer

You can do this manually for each string using a “light bulb”, but if you want to do this automatically for each string interpolator, I think you will have to write your own plugin (which may take some time if it is your first plugin).

You may have better answers / help in the JetBrains forums .

+2
source share

All Articles