Using Language Injection in Scala Code
Hi,
Now that we have language injection support for Scala (many thanks for this!), I'm trying to figure out how to actually use it. I've included the .../redist/annotations.jar file as a dependency and can import and apply the annotations (to val definitions and formal parameters), but they seem to have no effect. I created deliberately erroneous regular expression and XPath literals, but there was no feedback to that effect.
Is the language injection support fully operational? If so, what's the right way to use it? Is there any kind of documentation or notes on how to use this feature in Scala code?
Randall Schulz
Please sign in to leave a comment.
Here's the list of pre-configured injections for Scala: scalaInjections.xml (may be edited through Settings / Langauge Injection)
@Language annotation, "regexp".r and "pattern".format are not implemented yet (i'm working on it right now)
> Here's the list of pre-configured injections for Scala: scalaInjections.xml (may be edited through Settings / Langauge Injection)
While I'm sure that's got every last detail required, it's not particularly human-friendly...
In any event, what feedback should I expect to see in the IDEA editor when the string is not valid for the langauge specified? I seem to get no feedback.
Randall Schulz
The string literal must be a direct argument of one of the methods in that XML file Pavel posted.
Eh? I can't mark the formal parameters of my own methods with, say, @Language("XPath") and have its actual, String-literal arguments validated? And if not, what good is it?
Randall Schulz
> While I'm sure that's got every last detail required, it's not particularly human-friendly...
Look at Settings / Language injection for more human-readable presentation.
> Eh? I can't mark the formal parameters of my own methods with, say, @Language("XPath") and have its actual, String-literal arguments validated?
Not _yet_ ;)
>And if not, what good is it?
It's good for predefined suff like Session.createQuery("select * from Foo"), Pattern.compile("\\d+"), etc.
I shall exercise patience. ... For now!
RRS
done: language injection annotation for vals, vars, assignments and class parameters
todo: method and constructor parameters
Thank you, Pavel!
RRS
At last, completely done.
We've seen some performance issues with this, see: http://youtrack.jetbrains.net/issue/SCL-2592
-jason