关于传递参数等的非常基本的时髦编程问题



所以Intellij IDEA中基于Groovy的宏是我学习Groovy的借口。

时髦版本:2.4.9 JVM:1.8.0_144 供应商:甲骨文公司 操作系统:视窗 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:pathtoscript.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:pathtoscriptpasteIvyDependenciesAsMaven.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);
    ^

这是有道理的,但我不知道用这种语言该怎么做。尝试了一些变化,但没有骰子。 蛛丝马迹?想法?骨头?

将脚本更改为:

println _1
println _editor

最新更新