Advanced Live Templates with Groovy scripting
Answered
So I want to copy a colon separated Ivy style dependency and then paste it as a maven style XML dependency. I've created a Live Template with $GROOVY$ as the variable name and Expression I'm trying to use looks like this:
groovyScript(C:\path\to\script\script.groovy,clipboard())
Is this correct? This would mean that the first parameter is a multi-line String. Possibly a long one.
I'm a novice Groovy scripter. What should I return? It doesn't seem like my script is working. Is there an example that does work of something similar anywhere? Just something that gets information to and from the script would be grand.
Please sign in to leave a comment.
Use the forward slashes and double quote the file path, see also https://stackoverflow.com/questions/35405836/how-to-pass-variable-to-groovy-code-in-intellij-idea-live-templates-groovy-scrip.
OK, that seems to have helped. Still can't figure out how to get information to and back from the script though.
Error looks more reasonable though:
Clipboard contents (the argument to the script) should be in the script binding under name "_1". This is also described in the help: https://www.jetbrains.com/help/idea/live-template-variables.html
Wow. For some reason, I just couldn't take that underscore number stuff seriously but I guess that is what I'll try next.