本文整理汇总了Java中com.intellij.debugger.engine.evaluation.EvaluationContext类的典型用法代码示例。如果您正苦于以下问题:Java EvaluationContext类的具体用法?Java EvaluationContext怎么用?Java EvaluationContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EvaluationContext类属于com.intellij.debugger.engine.evaluation包,在下文中一共展示了EvaluationContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: evaluateCondition
import com.intellij.debugger.engine.evaluation.EvaluationContext; //导入依赖的package包/类
@Override
public ThreeState evaluateCondition(@NotNull EvaluationContext context,
@NotNull StackFrameProxyImpl frame,
@NotNull Location location,
@NotNull String expression) {
for (PositionManager positionManager : myPositionManagers) {
if (positionManager instanceof PositionManagerEx) {
try {
ThreeState result = ((PositionManagerEx)positionManager).evaluateCondition(context, frame, location, expression);
if (result != ThreeState.UNSURE) {
return result;
}
}
catch (Throwable e) {
LOG.error(e);
}
}
}
return ThreeState.UNSURE;
}
示例2: calcLabel
import com.intellij.debugger.engine.evaluation.EvaluationContext; //导入依赖的package包/类
@SuppressWarnings({"HardCodedStringLiteral"})
public String calcLabel(ValueDescriptor valueDescriptor, EvaluationContext evaluationContext, DescriptorLabelListener labelListener) {
Value value = valueDescriptor.getValue();
StringBuilder buf = new StringBuilder();
if (value == null) {
return "null";
}
else if (value instanceof CharValue) {
PrimitiveRenderer.appendCharValue((CharValue)value, buf);
buf.append(' ');
appendHexValue((PrimitiveValue)value, buf);
return buf.toString();
}
else {
appendHexValue((PrimitiveValue)value, buf);
return buf.toString();
}
}
示例3: calcValueIcon
import com.intellij.debugger.engine.evaluation.EvaluationContext; //导入依赖的package包/类
public Icon calcValueIcon(ValueDescriptor descriptor, EvaluationContext evaluationContext, DescriptorLabelListener listener) throws EvaluateException {
final Value value = descriptor.getValue();
if (value instanceof ObjectReference) {
try {
final ObjectReference objRef = (ObjectReference)value;
final ReferenceType refType = objRef.referenceType();
final Field valueField = refType.fieldByName("value");
if (valueField != null) {
final Value rgbValue = objRef.getValue(valueField);
if (rgbValue instanceof IntegerValue) {
@SuppressWarnings("UseJBColor")
final Color color = new Color(((IntegerValue)rgbValue).value(), true);
return new ColorIcon(16, 12, color, true);
}
}
}
catch (Exception e) {
throw new EvaluateException(e.getMessage(), e);
}
}
return null;
}
示例4: buildChildren
import com.intellij.debugger.engine.evaluation.EvaluationContext; //导入依赖的package包/类
public void buildChildren(final Value value, final ChildrenBuilder builder, final EvaluationContext evaluationContext) {
final NodeManager nodeManager = builder.getNodeManager();
try {
final ValueDescriptor parentDescriptor = builder.getParentDescriptor();
final Value childrenValue = evaluateChildren(
evaluationContext.createEvaluationContext(value), parentDescriptor
);
NodeRenderer renderer = getChildrenRenderer(childrenValue, parentDescriptor);
renderer.buildChildren(childrenValue, builder, evaluationContext);
}
catch (final EvaluateException e) {
List<DebuggerTreeNode> errorChildren = new ArrayList<DebuggerTreeNode>();
errorChildren.add(nodeManager.createMessageNode(DebuggerBundle.message("error.unable.to.evaluate.expression") + " " + e.getMessage()));
builder.setChildren(errorChildren);
}
}
示例5: defineClass
import com.intellij.debugger.engine.evaluation.EvaluationContext; //导入依赖的package包/类
public static void defineClass(String name,
byte[] bytes,
EvaluationContext context,
DebugProcess process,
ClassLoaderReference classLoader) throws EvaluateException {
try {
VirtualMachineProxyImpl proxy = (VirtualMachineProxyImpl)process.getVirtualMachineProxy();
Method defineMethod =
((ClassType)classLoader.referenceType()).concreteMethodByName("defineClass", "(Ljava/lang/String;[BII)Ljava/lang/Class;");
StringReference nameObj = proxy.mirrorOf(name);
DebuggerUtilsEx.keep(nameObj, context);
process.invokeMethod(context, classLoader, defineMethod,
Arrays.asList(nameObj,
mirrorOf(bytes, context, process),
proxy.mirrorOf(0),
proxy.mirrorOf(bytes.length)));
}
catch (Exception e) {
throw new EvaluateException("Error during class " + name + " definition: " + e, e);
}
}
示例6: createURLArray
import com.intellij.debugger.engine.evaluation.EvaluationContext; //导入依赖的package包/类
private static ArrayReference createURLArray(EvaluationContext context)
throws EvaluateException, InvocationException, InvalidTypeException, ClassNotLoadedException, IncompatibleThreadStateException {
DebugProcess process = context.getDebugProcess();
ArrayType arrayType = (ArrayType)process.findClass(context, "java.net.URL[]", context.getClassLoader());
ArrayReference arrayRef = arrayType.newInstance(1);
DebuggerUtilsEx.keep(arrayRef, context);
ClassType classType = (ClassType)process.findClass(context, "java.net.URL", context.getClassLoader());
VirtualMachineProxyImpl proxy = (VirtualMachineProxyImpl)process.getVirtualMachineProxy();
StringReference url = proxy.mirrorOf("file:a");
DebuggerUtilsEx.keep(url, context);
ObjectReference reference = process.newInstance(context,
classType,
classType.concreteMethodByName(JVMNameUtil.CONSTRUCTOR_NAME, "(Ljava/lang/String;)V"),
Collections.singletonList(url));
DebuggerUtilsEx.keep(reference, context);
arrayRef.setValues(Collections.singletonList(reference));
return arrayRef;
}
示例7: buildChildren
import com.intellij.debugger.engine.evaluation.EvaluationContext; //导入依赖的package包/类
public void buildChildren(final Value value, final ChildrenBuilder builder, final EvaluationContext evaluationContext) {
final NodeManager nodeManager = builder.getNodeManager();
try {
final ValueDescriptor parentDescriptor = builder.getParentDescriptor();
final Value childrenValue = evaluateChildren(
evaluationContext.createEvaluationContext(value), parentDescriptor
);
NodeRenderer renderer = getLastChildrenRenderer(parentDescriptor);
if (renderer == null || childrenValue == null || !renderer.isApplicable(childrenValue.type())) {
renderer = DebugProcessImpl.getDefaultRenderer(childrenValue != null ? childrenValue.type() : null);
parentDescriptor.putUserData(LAST_CHILDREN_RENDERER, renderer);
}
renderer.buildChildren(childrenValue, builder, evaluationContext);
}
catch (final EvaluateException e) {
List<DebuggerTreeNode> errorChildren = new ArrayList<DebuggerTreeNode>();
errorChildren.add(nodeManager.createMessageNode(DebuggerBundle.message("error.unable.to.evaluate.expression") + " " + e.getMessage()));
builder.setChildren(errorChildren);
}
}
示例8: evaluateCondition
import com.intellij.debugger.engine.evaluation.EvaluationContext; //导入依赖的package包/类
@Override
public ThreeState evaluateCondition(@NotNull EvaluationContext context, @NotNull StackFrameProxyImpl frame, @NotNull Location location, @NotNull String expression)
{
for(PositionManager positionManager : myPositionManagers)
{
if(positionManager instanceof PositionManagerEx)
{
try
{
ThreeState result = ((PositionManagerEx) positionManager).evaluateCondition(context, frame, location, expression);
if(result != ThreeState.UNSURE)
{
return result;
}
}
catch(Throwable e)
{
LOG.error(e);
}
}
}
return ThreeState.UNSURE;
}
示例9: calcLabel
import com.intellij.debugger.engine.evaluation.EvaluationContext; //导入依赖的package包/类
@Override
@SuppressWarnings({"HardCodedStringLiteral"})
public String calcLabel(ValueDescriptor valueDescriptor, EvaluationContext evaluationContext, DescriptorLabelListener labelListener)
{
Value value = valueDescriptor.getValue();
StringBuilder buf = new StringBuilder();
if(value == null)
{
return "null";
}
else if(value instanceof CharValue)
{
PrimitiveRenderer.appendCharValue((CharValue) value, buf);
buf.append(' ');
appendHexValue((PrimitiveValue) value, buf);
return buf.toString();
}
else
{
appendHexValue((PrimitiveValue) value, buf);
return buf.toString();
}
}
示例10: buildChildren
import com.intellij.debugger.engine.evaluation.EvaluationContext; //导入依赖的package包/类
@Override
public void buildChildren(Value value, ChildrenBuilder builder, EvaluationContext evaluationContext)
{
NodeManager nodeManager = builder.getNodeManager();
NodeDescriptorFactory descriptorFactory = builder.getDescriptorManager();
List<DebuggerTreeNode> children = new ArrayList<>();
int idx = 0;
for(ChildInfo childInfo : myChildren)
{
UserExpressionData data = new UserExpressionData((ValueDescriptorImpl) builder.getParentDescriptor(), getClassName(), childInfo.myName, childInfo.myExpression);
data.setEnumerationIndex(idx++);
UserExpressionDescriptor descriptor = descriptorFactory.getUserExpressionDescriptor(builder.getParentDescriptor(), data);
if(childInfo.myOnDemand)
{
descriptor.putUserData(OnDemandRenderer.ON_DEMAND_CALCULATED, false);
}
children.add(nodeManager.createNode(descriptor, evaluationContext));
}
builder.addChildren(children, !myAppendDefaultChildren);
if(myAppendDefaultChildren)
{
DebugProcessImpl.getDefaultRenderer(value).buildChildren(value, builder, evaluationContext);
}
}
示例11: calcValueIcon
import com.intellij.debugger.engine.evaluation.EvaluationContext; //导入依赖的package包/类
@Override
public Icon calcValueIcon(final ValueDescriptor descriptor, final EvaluationContext evaluationContext, final DescriptorLabelListener listener) throws EvaluateException
{
EvaluationContextImpl evalContext = ((EvaluationContextImpl) evaluationContext);
DebugProcessImpl debugProcess = evalContext.getDebugProcess();
if(DebuggerUtilsImpl.isRemote(debugProcess))
{
return null;
}
debugProcess.getManagerThread().schedule(new SuspendContextCommandImpl(evalContext.getSuspendContext())
{
@Override
public void contextAction() throws Exception
{
String getterName = AllIcons.Debugger.Value.getIconHeight() <= 16 ? "iconToBytesPreviewNormal" : "iconToBytesPreviewRetina";
descriptor.setValueIcon(ImageObjectRenderer.getIcon(evaluationContext, descriptor.getValue(), getterName));
listener.labelChanged();
}
});
return null;
}
示例12: buildChildren
import com.intellij.debugger.engine.evaluation.EvaluationContext; //导入依赖的package包/类
public void buildChildren(final Value value, final ChildrenBuilder builder, final EvaluationContext evaluationContext)
{
final NodeManager nodeManager = builder.getNodeManager();
try
{
final ValueDescriptor parentDescriptor = builder.getParentDescriptor();
final Value childrenValue = evaluateChildren(evaluationContext.createEvaluationContext(value), parentDescriptor);
NodeRenderer renderer = getChildrenRenderer(childrenValue, parentDescriptor);
renderer.buildChildren(childrenValue, builder, evaluationContext);
}
catch(final EvaluateException e)
{
List<DebuggerTreeNode> errorChildren = new ArrayList<>();
errorChildren.add(nodeManager.createMessageNode(DebuggerBundle.message("error.unable.to.evaluate.expression") + " " + e.getMessage()));
builder.setChildren(errorChildren);
}
}
示例13: getIcon
import com.intellij.debugger.engine.evaluation.EvaluationContext; //导入依赖的package包/类
@Nullable
static ImageIcon getIcon(EvaluationContext evaluationContext, Value obj, String methodName)
{
try
{
Value bytes = getImageBytes(evaluationContext, obj, methodName);
byte[] data = readBytes(bytes);
if(data != null)
{
return new ImageIcon(data);
}
}
catch(Exception e)
{
LOG.info("Exception while getting image data", e);
}
return null;
}
示例14: getImageBytes
import com.intellij.debugger.engine.evaluation.EvaluationContext; //导入依赖的package包/类
private static Value getImageBytes(EvaluationContext evaluationContext, Value obj, String methodName) throws EvaluateException
{
DebugProcess process = evaluationContext.getDebugProcess();
EvaluationContext copyContext = evaluationContext.createEvaluationContext(obj);
ClassType helperClass = ClassLoadingUtils.getHelperClass(ImageSerializer.class.getName(), copyContext, process);
if(helperClass != null)
{
List<Method> methods = helperClass.methodsByName(methodName);
if(!methods.isEmpty())
{
return process.invokeMethod(copyContext, helperClass, methods.get(0), Collections.singletonList(obj));
}
}
return null;
}
示例15: evaluate
import com.intellij.debugger.engine.evaluation.EvaluationContext; //导入依赖的package包/类
@Nullable
Value evaluate(final EvaluationContext context) throws EvaluateException
{
ExpressionEvaluator evaluator = myEvaluator;
if(evaluator == null)
{
@SuppressWarnings("ConstantConditions") Location location = context.getFrameProxy().location();
evaluator = myEvaluatorCache.get(location);
if(evaluator == null && !StringUtil.isEmpty(myExpression))
{
evaluator = ApplicationManager.getApplication().runReadAction((ThrowableComputable<ExpressionEvaluator, EvaluateException>) () ->
{
SourcePosition sourcePosition = ContextUtil.getSourcePosition(context);
PsiElement contextElement = ContextUtil.getContextElement(sourcePosition);
return EvaluatorBuilderImpl.build(new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, myExpression), contextElement, sourcePosition, context.getProject());
});
myEvaluatorCache.put(location, evaluator);
}
}
if(evaluator != null)
{
return evaluator.evaluate(context);
}
return null;
}