Live Templates for Scala

I'm trying to write some live templates that would have some parameters that could be filled in.  In particular, I'm trying to understand the "Expression" and "Default value" field.  

There are a number of expressions documented at , but some of the existing templates have undocumented Scala-specific expressions, such as:

scalaVariableOfType('scala.Option") // I guess this will suggests variables in scope with the class specified by the string.  Can it support parameterized types?

suggestScalaVariableName("option", OPTION) // I'm guessing this is a vararg function that will suggest either the variable name "option", or same name as the OPTION Template variable?

Is this interpretation right, and are there any other useful documented or undocumented expressions?

1 comment
Comment actions Permalink

scalaVariableOfType macro works only for classes. So scala.Option will return all variables, which type is Option of anything. Additionally "foreach" means anything, which has method foreach.
suggestScalaVariableName even more limited. It can get only two possible parameters: "option" or "foreach. First can search variables among variables, which has type Option, and second between variables, which has method foreach.

You can check sourcecode:

Anyway "Live templates" is slightly outdated feature, and it needs a lot of updates (any contributions are welcome;)). I think some work will be done before IDEA 12 release in "Live templates" direction.

Best regards,
Alexander Podkhalyuzin.


Please sign in to leave a comment.