Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

using Scala in IntelliJ, you can already do

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

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

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

Does anyone know how to fiddle with the custom-language-injection functionality to nicely highlight these custom string interpolators? I've messed around with the stuff under the File->Settings->Language Injections but it seems really confusing, and I can't find any existing injections that do the magic string interpolation syntax. Presumably that one is hard coded (since it also has the nice code navigation features) but i'm hopeful there'll be some way of getting it to recognize the nice something"..." syntax and highlighting it nicely for me.

like image 751
Li Haoyi Avatar asked Jan 01 '13 06:01

Li Haoyi


1 Answers

You could do it by hand for each string using the "light bulb", but if you want to do it 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 JetBrains forums directly.

like image 58
Bastien Jansen Avatar answered Oct 23 '22 12:10

Bastien Jansen