让主java类评估groovy scipt
Binding binding = new Binding();
binding.setProperty("text", "some text");
CompilerConfiguration configuration = new CompilerConfiguration();
configuration.setScriptBaseClass(MyBaseClass.class.getName());
GroovyShell groovyShell = new GroovyShell(binding, configuration);
result = groovyShell.evaluate(file);
为了在idea (和其他idea)中拥有自动补全的groovy脚本,我使用gdsl文件
def ctx = context(scope: scriptScope())
contributor(ctx) {
property name: "text", type: "java.lang.String"
method name: 'annotate', type: 'void', params: [closure: 'groovy.lang.Closure']
}
但是我想放入gdsl来获得集成开发环境的提示,并自动完成我所有的类方法。
发布于 2017-07-18 21:00:42
试试这段代码
def ctx = context(scope: scriptScope())
contributor(ctx, {
delegatesTo(findClass('com.example.MyBaseClass'))
})
https://stackoverflow.com/questions/42027159
复制相似问题