use of com.intellij.openapi.compiler.ClassObject in project intellij-community by JetBrains.
the class CompilingEvaluator method defineClasses.
private ClassType defineClasses(Collection<ClassObject> classes, EvaluationContext context, DebugProcess process, ClassLoaderReference classLoader) throws EvaluateException {
for (ClassObject cls : classes) {
if (cls.getPath().contains(GEN_CLASS_NAME)) {
final byte[] content = cls.getContent();
if (content != null) {
final byte[] bytes = changeSuperToMagicAccessor(content);
ClassLoadingUtils.defineClass(cls.getClassName(), bytes, context, process, classLoader);
}
}
}
return (ClassType) process.findClass(context, getGenClassQName(), classLoader);
}
use of com.intellij.openapi.compiler.ClassObject in project intellij-community by JetBrains.
the class CompilingEvaluator method evaluate.
@Override
public Value evaluate(final EvaluationContext evaluationContext) throws EvaluateException {
DebugProcess process = evaluationContext.getDebugProcess();
EvaluationContextImpl autoLoadContext = ((EvaluationContextImpl) evaluationContext).createEvaluationContext(evaluationContext.getThisObject());
autoLoadContext.setAutoLoadClasses(true);
ClassLoaderReference classLoader = ClassLoadingUtils.getClassLoader(autoLoadContext, process);
autoLoadContext.setClassLoader(classLoader);
String version = ((VirtualMachineProxyImpl) process.getVirtualMachineProxy()).version();
Collection<ClassObject> classes = compile(JdkVersionUtil.getVersion(version));
defineClasses(classes, autoLoadContext, process, classLoader);
try {
// invoke base evaluator on call code
SourcePosition position = ContextUtil.getSourcePosition(evaluationContext);
ExpressionEvaluator evaluator = DebuggerInvocationUtil.commitAndRunReadAction(myProject, new EvaluatingComputable<ExpressionEvaluator>() {
@Override
public ExpressionEvaluator compute() throws EvaluateException {
TextWithImports callCode = getCallCode();
PsiElement copyContext = myData.getAnchor();
CodeFragmentFactory factory = DebuggerUtilsEx.findAppropriateCodeFragmentFactory(callCode, copyContext);
return factory.getEvaluatorBuilder().build(factory.createCodeFragment(callCode, copyContext, myProject), position);
}
});
return evaluator.evaluate(autoLoadContext);
} catch (Exception e) {
throw new EvaluateException("Error during generated code invocation " + e, e);
}
}
Aggregations