2017-02-03 28 views
0

Есть главный класс Java с оценкой заводной sciptКак установить gdsl заводной базовый сценарий объект

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); 

Чтобы иметь автозаполнение заводных скриптов в идее (и других Идах), я использую 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')) 
})