因此,Intellij IDEA中基于Groovy的宏是我学习Groovy的借口。
Groovy版本:2.4.9 JVM:1.8.0_144供应商:Oracle Corporation操作系统:Windows 10
请参阅IntelliJ文档中的groovyScript("groovy code")
:
https://www.jetbrains.com/help/idea/live-template-variables.html
我有一个IntelliJ调用的脚本,它将参数绑定为_1,_2 ... _ n,还有一个_editor ...参数? IDK是否是参数。必须有一些方法可以将转换后的输入恢复出去。
这是我的测试脚本:
public class IvyPaister {
public static void main(String[] args) {
println _1
println _editor
}
}
以下是错误:
startup failed:
C:\path\to\script.groovy: 4: Apparent variable
'_1' was found in a static scope but doesn't refer to a local variable, static field or class.
Possible causes:
You attempted to reference a variable in the binding or an instance variable from a static
context.
You misspelled a classname or statically imported field. Please check the spelling.
You attempted to use a method '_1' but left out brackets in a place not allowed by the grammar.
@ line 4, column 41.
yPaister app = new IvyPaister(_1, _edito
^
C:\path\to\script\pasteIvyDependenciesAsMaven.groovy: 4: Apparent variable
'_editor' was found in a static scope but doesn't refer to a local variable, static field or
class. Possible causes:
You attempted to reference a variable in the binding or an instance variable from a static
context.
You misspelled a classname or statically imported field. Please check the spelling.
You attempted to use a method '_editor' but left out brackets in a place not allowed by the
grammar.
@ line 4, column 45.
ster app = new IvyPaister(_1, _editor);
^
这很有道理,但我不知道用这种语言怎么做。尝试了一些变化,但没有骰子。线索?想法?骨头?
答案 0 :(得分:0)
将您的脚本更改为:
println _1
println _editor