Search in sources :

Example 1 with ProxyGeneratorAdapter

use of org.codehaus.groovy.runtime.ProxyGeneratorAdapter in project groovy-core by groovy.

the class InlinedASTCustomizerFactory method postCompleteNode.

public Object postCompleteNode(final FactoryBuilderSupport factory, final Object parent, final Object node) {
    if (node instanceof Map) {
        Map map = (Map) node;
        ProxyGeneratorAdapter adapter = new ProxyGeneratorAdapter(map, map.containsKey("superClass") ? (Class) map.get("superClass") : CompilationCustomizer.class, map.containsKey("interfaces") ? (Class[]) map.get("interfaces") : null, this.getClass().getClassLoader(), false, null);
        Object phase = map.get("phase");
        if (!(phase instanceof CompilePhase)) {
            phase = CompilePhase.valueOf(phase.toString());
        }
        return adapter.proxy(map, phase);
    }
    return node;
}
Also used : CompilePhase(org.codehaus.groovy.control.CompilePhase) ProxyGeneratorAdapter(org.codehaus.groovy.runtime.ProxyGeneratorAdapter) CompilationCustomizer(org.codehaus.groovy.control.customizers.CompilationCustomizer) Map(java.util.Map) HashMap(java.util.HashMap)

Example 2 with ProxyGeneratorAdapter

use of org.codehaus.groovy.runtime.ProxyGeneratorAdapter in project groovy by apache.

the class InlinedASTCustomizerFactory method postCompleteNode.

public Object postCompleteNode(final FactoryBuilderSupport factory, final Object parent, final Object node) {
    if (node instanceof Map) {
        Map map = (Map) node;
        ProxyGeneratorAdapter adapter = new ProxyGeneratorAdapter(map, map.containsKey("superClass") ? (Class) map.get("superClass") : CompilationCustomizer.class, map.containsKey("interfaces") ? (Class[]) map.get("interfaces") : null, this.getClass().getClassLoader(), false, null);
        Object phase = map.get("phase");
        if (!(phase instanceof CompilePhase)) {
            phase = CompilePhase.valueOf(phase.toString());
        }
        return adapter.proxy(map, phase);
    }
    return node;
}
Also used : CompilePhase(org.codehaus.groovy.control.CompilePhase) ProxyGeneratorAdapter(org.codehaus.groovy.runtime.ProxyGeneratorAdapter) CompilationCustomizer(org.codehaus.groovy.control.customizers.CompilationCustomizer) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

HashMap (java.util.HashMap)2 Map (java.util.Map)2 CompilePhase (org.codehaus.groovy.control.CompilePhase)2 CompilationCustomizer (org.codehaus.groovy.control.customizers.CompilationCustomizer)2 ProxyGeneratorAdapter (org.codehaus.groovy.runtime.ProxyGeneratorAdapter)2