From fa91e1ccb0fe9ed616f62feb1b4230fc89fead39 Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 23 Nov 2012 21:51:41 +0100 Subject: [PATCH] [^jeka] fix groovy compiler tests (cherry-picked from 929fdfa) --- .../groovy/compiler/rt/GroovycRunner.java | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/plugins/groovy/rt/src/org/jetbrains/groovy/compiler/rt/GroovycRunner.java b/plugins/groovy/rt/src/org/jetbrains/groovy/compiler/rt/GroovycRunner.java index dc137fb6d656..f534dedfea8d 100644 --- a/plugins/groovy/rt/src/org/jetbrains/groovy/compiler/rt/GroovycRunner.java +++ b/plugins/groovy/rt/src/org/jetbrains/groovy/compiler/rt/GroovycRunner.java @@ -328,14 +328,6 @@ public class GroovycRunner { final CompilerConfiguration config, final String finalOutput, final GroovyClassLoader classLoader) { - try { - if (forStubs) { - return createStubGenerator(config, classLoader); - } - } - catch (NoClassDefFoundError ignore) { // older groovy distributions just don't have stub generation capability - } - final GroovyClassLoader transformLoader = new GroovyClassLoader(classLoader) { public Enumeration getResources(String name) throws IOException { if (name.endsWith("org.codehaus.groovy.transform.ASTTransformation")) { @@ -358,6 +350,15 @@ public class GroovycRunner { return super.getResources(name); } }; + + try { + if (forStubs) { + return createStubGenerator(config, classLoader, transformLoader); + } + } + catch (NoClassDefFoundError ignore) { // older groovy distributions just don't have stub generation capability + } + CompilationUnit unit; try { unit = new CompilationUnit(config, null, classLoader, transformLoader) { @@ -385,10 +386,14 @@ public class GroovycRunner { return unit; } - private static CompilationUnit createStubGenerator(final CompilerConfiguration config, final GroovyClassLoader classLoader) { + private static CompilationUnit createStubGenerator(final CompilerConfiguration config, final GroovyClassLoader classLoader, final GroovyClassLoader transformLoader) { JavaAwareCompilationUnit unit = new JavaAwareCompilationUnit(config, classLoader) { private boolean annoRemovedAdded; + public GroovyClassLoader getTransformLoader() { + return transformLoader; + } + @Override public void addPhaseOperation(PrimaryClassNodeOperation op, int phase) { if (!annoRemovedAdded && phase == Phases.CONVERSION && op.getClass().getName().startsWith("org.codehaus.groovy.tools.javac.JavaAwareCompilationUnit$")) {