use of com.intellij.debugger.engine.evaluation.EvaluateException in project kotlin by JetBrains.
the class DebuggerSteppingHelper method createStepOutCommand.
public static DebugProcessImpl.ResumeCommand createStepOutCommand(final SuspendContextImpl suspendContext, final boolean ignoreBreakpoints, final List<KtNamedFunction> inlineFunctions, final KtFunctionLiteral inlineArgument) {
final DebugProcessImpl debugProcess = suspendContext.getDebugProcess();
return debugProcess.new ResumeCommand(suspendContext) {
@Override
public void contextAction() {
try {
StackFrameProxyImpl frameProxy = suspendContext.getFrameProxy();
if (frameProxy != null) {
Action action = KotlinSteppingCommandProviderKt.getStepOutAction(frameProxy.location(), suspendContext, inlineFunctions, inlineArgument);
createStepRequest(suspendContext, getContextThread(), debugProcess.getVirtualMachineProxy().eventRequestManager(), StepRequest.STEP_LINE, StepRequest.STEP_OUT);
action.apply(debugProcess, suspendContext, ignoreBreakpoints);
return;
}
debugProcess.createStepOverCommand(suspendContext, ignoreBreakpoints).contextAction();
} catch (EvaluateException ignored) {
}
}
};
}
use of com.intellij.debugger.engine.evaluation.EvaluateException in project kotlin by JetBrains.
the class DebuggerSteppingHelper method getCurrentClassName.
// copied from DebugProcessImpl.getActiveFilters
@Nullable
private static String getCurrentClassName(ThreadReferenceProxyImpl thread) {
try {
if (thread != null && thread.frameCount() > 0) {
StackFrameProxyImpl stackFrame = thread.frame(0);
if (stackFrame != null) {
Location location = stackFrame.location();
ReferenceType referenceType = location == null ? null : location.declaringType();
if (referenceType != null) {
return referenceType.name();
}
}
}
} catch (EvaluateException ignored) {
}
return null;
}
use of com.intellij.debugger.engine.evaluation.EvaluateException in project intellij-community by JetBrains.
the class DebuggerTreeCreatorImpl method createDescriptorByNode.
@Override
public void createDescriptorByNode(Object node, final ResultConsumer<Pair<NodeDescriptorImpl, String>> resultConsumer) {
if (node instanceof DebuggerTreeNodeImpl) {
final DebuggerTreeNodeImpl debuggerTreeNode = (DebuggerTreeNodeImpl) node;
final DebuggerContextImpl context = DebuggerManagerEx.getInstanceEx(myProject).getContext();
context.getDebugProcess().getManagerThread().schedule(new DebuggerContextCommandImpl(context) {
@Override
public void threadAction() {
try {
final TextWithImports evaluationText = DebuggerTreeNodeExpression.createEvaluationText(debuggerTreeNode, context);
resultConsumer.onSuccess(Pair.create(debuggerTreeNode.getDescriptor(), evaluationText.getText()));
} catch (EvaluateException e) {
resultConsumer.onFailure(e);
}
}
});
}
}
use of com.intellij.debugger.engine.evaluation.EvaluateException in project intellij-community by JetBrains.
the class JavaStackFrame method buildVariablesThreadAction.
// copied from DebuggerTree
private void buildVariablesThreadAction(DebuggerContextImpl debuggerContext, XValueChildrenList children, XCompositeNode node) {
try {
final EvaluationContextImpl evaluationContext = debuggerContext.createEvaluationContext();
if (evaluationContext == null) {
return;
}
if (!debuggerContext.isEvaluationPossible()) {
node.setErrorMessage(MessageDescriptor.EVALUATION_NOT_POSSIBLE.getLabel());
//myChildren.add(myNodeManager.createNode(MessageDescriptor.EVALUATION_NOT_POSSIBLE, evaluationContext));
}
final Location location = myDescriptor.getLocation();
final ObjectReference thisObjectReference = myDescriptor.getThisObject();
if (thisObjectReference != null) {
ValueDescriptorImpl thisDescriptor = myNodeManager.getThisDescriptor(null, thisObjectReference);
children.add(JavaValue.create(thisDescriptor, evaluationContext, myNodeManager));
} else if (location != null) {
StaticDescriptorImpl staticDecriptor = myNodeManager.getStaticDescriptor(myDescriptor, location.declaringType());
if (staticDecriptor.isExpandable()) {
children.addTopGroup(new JavaStaticGroup(staticDecriptor, evaluationContext, myNodeManager));
}
}
DebugProcessImpl debugProcess = debuggerContext.getDebugProcess();
if (debugProcess == null) {
return;
}
// add last method return value if any
final Pair<Method, Value> methodValuePair = debugProcess.getLastExecutedMethod();
if (methodValuePair != null && myDescriptor.getUiIndex() == 0) {
ValueDescriptorImpl returnValueDescriptor = myNodeManager.getMethodReturnValueDescriptor(myDescriptor, methodValuePair.getFirst(), methodValuePair.getSecond());
children.add(JavaValue.create(returnValueDescriptor, evaluationContext, myNodeManager));
}
// add context exceptions
Set<ObjectReference> exceptions = new HashSet<>();
for (Pair<Breakpoint, Event> pair : DebuggerUtilsEx.getEventDescriptors(debuggerContext.getSuspendContext())) {
Event debugEvent = pair.getSecond();
if (debugEvent instanceof ExceptionEvent) {
ObjectReference exception = ((ExceptionEvent) debugEvent).exception();
if (exception != null) {
exceptions.add(exception);
}
}
}
exceptions.forEach(e -> children.add(JavaValue.create(myNodeManager.getThrownExceptionObjectDescriptor(myDescriptor, e), evaluationContext, myNodeManager)));
try {
buildVariables(debuggerContext, evaluationContext, debugProcess, children, thisObjectReference, location);
//if (classRenderer.SORT_ASCENDING) {
// Collections.sort(myChildren, NodeManagerImpl.getNodeComparator());
//}
} catch (EvaluateException e) {
node.setErrorMessage(e.getMessage());
//myChildren.add(myNodeManager.createMessageNode(new MessageDescriptor(e.getMessage())));
}
} catch (InvalidStackFrameException e) {
LOG.info(e);
//myChildren.clear();
//notifyCancelled();
} catch (InternalException e) {
if (e.errorCode() == 35) {
node.setErrorMessage(DebuggerBundle.message("error.corrupt.debug.info", e.getMessage()));
//myChildren.add(
// myNodeManager.createMessageNode(new MessageDescriptor(DebuggerBundle.message("error.corrupt.debug.info", e.getMessage()))));
} else {
throw e;
}
}
}
use of com.intellij.debugger.engine.evaluation.EvaluateException in project intellij-community by JetBrains.
the class JavaValue method computePresentation.
@Override
public void computePresentation(@NotNull final XValueNode node, @NotNull XValuePlace place) {
final SuspendContextImpl suspendContext = myEvaluationContext.getSuspendContext();
myEvaluationContext.getManagerThread().schedule(new SuspendContextCommandImpl(suspendContext) {
@Override
public Priority getPriority() {
return Priority.NORMAL;
}
@Override
protected void commandCancelled() {
node.setPresentation(null, new XErrorValuePresentation(DebuggerBundle.message("error.context.has.changed")), false);
}
@Override
public void contextAction() throws Exception {
if (node.isObsolete()) {
return;
}
if (!myContextSet) {
myValueDescriptor.setContext(myEvaluationContext);
}
myValueDescriptor.updateRepresentation(myEvaluationContext, new DescriptorLabelListener() {
@Override
public void labelChanged() {
Icon nodeIcon = DebuggerTreeRenderer.getValueIcon(myValueDescriptor);
final String value = getValueString();
@SuppressWarnings("ThrowableResultOfMethodCallIgnored") EvaluateException exception = myValueDescriptor.getEvaluateException();
XValuePresentation presentation = new JavaValuePresentation(value, myValueDescriptor.getIdLabel(), exception != null ? exception.getMessage() : null, myValueDescriptor);
if (myValueDescriptor.getLastRenderer() instanceof FullValueEvaluatorProvider) {
XFullValueEvaluator evaluator = ((FullValueEvaluatorProvider) myValueDescriptor.getLastRenderer()).getFullValueEvaluator(myEvaluationContext, myValueDescriptor);
if (evaluator != null) {
node.setFullValueEvaluator(evaluator);
}
} else if (value.length() > XValueNode.MAX_VALUE_LENGTH) {
node.setFullValueEvaluator(new JavaFullValueEvaluator(myEvaluationContext) {
@Override
public void evaluate(@NotNull final XFullValueEvaluationCallback callback) {
final ValueDescriptorImpl fullValueDescriptor = myValueDescriptor.getFullValueDescriptor();
fullValueDescriptor.updateRepresentation(myEvaluationContext, new DescriptorLabelListener() {
@Override
public void labelChanged() {
callback.evaluated(fullValueDescriptor.getValueText());
}
});
}
});
}
node.setPresentation(nodeIcon, presentation, myValueDescriptor.isExpandable());
}
});
}
});
}
Aggregations