如何设置GDSL Groovy脚本基本对象
问题描述:
有主要的Java类评估常规素文字如何设置GDSL Groovy脚本基本对象
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);
要在思想(和其他IDE)自动完成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 MyBaseClass以获得IDE提示和自动完成我所有的类方法。
答
试试这个代码
def ctx = context(scope: scriptScope())
contributor(ctx, {
delegatesTo(findClass('com.example.MyBaseClass'))
})