2017-02-03 4 views
0

Haben Haupt-Java-Klasse Auswertung groovy sciptWie GDSL groovy Skript Basisobjekt

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

zu haben, die automatische Vervollständigung groovy Skripte in Idee (und anderen IDEs) setzen, verwende ich GDSL Datei

def ctx = context(scope: scriptScope()) 

contributor(ctx) { 
    property name: "text", type: "java.lang.String" 
    method name: 'annotate', type: 'void', params: [closure: 'groovy.lang.Closure'] 
} 

Aber Ich möchte gdsl MyBaseClass einfügen, um IDE-Tipps zu erhalten und automatisch mit allen meinen Klassenmethoden zu vervollständigen.

Antwort

0

diesen Code Versuchen

def ctx = context(scope: scriptScope()) 

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