diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyCodeFragmentFactory.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyCodeFragmentFactory.java index 533a835ac1a2..7f658f565e36 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyCodeFragmentFactory.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyCodeFragmentFactory.java @@ -144,8 +144,8 @@ public class GroovyCodeFragmentFactory extends CodeFragmentFactory { javaText.append("final java.lang.ClassLoader |parentLoader = |clazz.getClassLoader();\n" + " final groovy.lang.GroovyClassLoader |loader = new groovy.lang.GroovyClassLoader(|parentLoader);\n" + " final java.lang.Class |c = |loader.parseClass("); - javaText.append("\"" + IMPORTS + "class DUMMY { " + - "public groovy.lang.Closure " + + javaText.append("\"" + IMPORTS + "class DUMMY" + new Random().nextInt(239) + " { " + + "public groovy.lang.Closure " + EVAL_NAME + " = {" + TEXT + "}}\""); javaText.append(", \"DUMMY.groovy\");\n" + " int |i;\n" + diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/GroovyDebuggerTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/GroovyDebuggerTest.groovy index b1b69809265e..ac5c3d2bb432 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/GroovyDebuggerTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/GroovyDebuggerTest.groovy @@ -50,6 +50,8 @@ import com.intellij.testFramework.builders.JavaModuleFixtureBuilder import com.intellij.testFramework.fixtures.impl.TempDirTestFixtureImpl import com.intellij.util.SystemProperties import com.intellij.util.concurrency.Semaphore +import junit.framework.Test +import junit.framework.TestSuite /** * @author peter */ @@ -155,6 +157,8 @@ package com class Foo { static bar = 2 int field = 3 + + String toString() { field as String } }""") @@ -173,6 +177,8 @@ println 2 //4 eval 'secondConstant', '1' eval 'mainConstant - secondConstant', '41' eval '(lst as List)[0].field', '3' + eval 'lst', '[3]' + eval 'lst.size()', '1' } } @@ -330,17 +336,16 @@ foo() } private void eval(final String codeText, String expected) throws EvaluateException { - Semaphore semaphore = new Semaphore() semaphore.down() - semaphore.down() EvaluationContextImpl ctx def item = new WatchItemDescriptor(project, new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, codeText)) managed { ctx = evaluationContext() item.setContext(ctx) - item.updateRepresentation(ctx, { semaphore.up() } as DescriptorLabelListener) + item.updateRepresentation(ctx, { } as DescriptorLabelListener) + semaphore.up() } assert semaphore.waitFor(10000): "too long evaluation: $item.label $item.evaluateException"