mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
unique dummy class name in groovy debugger evaluation
This commit is contained in:
+2
-2
@@ -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" +
|
||||
|
||||
@@ -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<Foo>)[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"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user