2017-02-03 57 views
0

有主要的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提示和自動完成我所有的類方法。

回答

0

試試這個代碼

def ctx = context(scope: scriptScope()) 

contributor(ctx, { 
    delegatesTo(findClass('com.example.MyBaseClass')) 
})