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. 

0
4 comments

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:

No such property: arg for class: scriptName

Tried args[] and arg[].
0

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

0

Wow. For some reason, I just couldn't take that underscore number stuff seriously but I guess that is what I'll try next.

0

Please sign in to leave a comment.