IDEA-131931 Debugger: Throwable at SuspendContextImpl.getDebugProcess() on opening Referring Objects dialog from itself - better fix

This commit is contained in:
Egor.Ushakov
2014-10-30 21:16:03 +03:00
parent 5598f017de
commit 07fef358da
3 changed files with 44 additions and 19 deletions
@@ -120,12 +120,17 @@ public class JavaValue extends XNamedValue implements NodeDescriptorProvider, XV
@Override
public void computePresentation(@NotNull final XValueNode node, @NotNull XValuePlace place) {
final SuspendContextImpl suspendContext = myEvaluationContext.getSuspendContext();
scheduleCommand(new SuspendContextCommandImpl(suspendContext) {
myEvaluationContext.getManagerThread().schedule(new SuspendContextCommandImpl(suspendContext) {
@Override
public Priority getPriority() {
return Priority.NORMAL;
}
@Override
protected void commandCancelled() {
node.setPresentation(null, new JavaValuePresentation("", null, DebuggerBundle.message("error.context.has.changed")), false);
}
@Override
public void contextAction() throws Exception {
if (!myContextSet) {
@@ -162,12 +167,17 @@ public class JavaValue extends XNamedValue implements NodeDescriptorProvider, XV
node.setFullValueEvaluator(new XFullValueEvaluator() {
@Override
public void startEvaluation(@NotNull final XFullValueEvaluationCallback callback) {
scheduleCommand(new SuspendContextCommandImpl(suspendContext) {
myEvaluationContext.getManagerThread().schedule(new SuspendContextCommandImpl(suspendContext) {
@Override
public Priority getPriority() {
return Priority.NORMAL;
}
@Override
protected void commandCancelled() {
callback.errorOccurred(DebuggerBundle.message("error.context.has.changed"));
}
@Override
public void contextAction() throws Exception {
final String valueAsString = myValueDescriptor.getValueText();
@@ -352,31 +362,36 @@ public class JavaValue extends XNamedValue implements NodeDescriptorProvider, XV
});
}
boolean scheduleCommand(SuspendContextCommandImpl command) {
return scheduleCommand(myEvaluationContext, null, command);
}
protected static boolean scheduleCommand(EvaluationContextImpl evaluationContext,
@Nullable XCompositeNode node,
SuspendContextCommandImpl command) {
if (evaluationContext.getSuspendContext().isResumed()) {
if (node != null) {
@NotNull final XCompositeNode node,
final SuspendContextCommandImpl command) {
evaluationContext.getManagerThread().schedule(new SuspendContextCommandImpl(command.getSuspendContext()) {
@Override
public void contextAction() throws Exception {
command.contextAction();
}
@Override
protected void commandCancelled() {
node.setErrorMessage(DebuggerBundle.message("error.context.has.changed"));
}
return false;
}
evaluationContext.getDebugProcess().getManagerThread().schedule(command);
});
return true;
}
@Override
public void computeSourcePosition(@NotNull final XNavigatable navigatable) {
scheduleCommand(new SuspendContextCommandImpl(myEvaluationContext.getSuspendContext()) {
myEvaluationContext.getManagerThread().schedule(new SuspendContextCommandImpl(myEvaluationContext.getSuspendContext()) {
@Override
public Priority getPriority() {
return Priority.NORMAL;
}
@Override
protected void commandCancelled() {
navigatable.setSourcePosition(null);
}
@Override
public void contextAction() throws Exception {
ApplicationManager.getApplication().runReadAction(new Runnable() {
@@ -452,9 +467,7 @@ public class JavaValue extends XNamedValue implements NodeDescriptorProvider, XV
public String getEvaluationExpression() {
if (evaluationExpression == null) {
// TODO: change API to allow to calculate it asynchronously
if (myEvaluationContext.getSuspendContext().isResumed()) return null;
DebugProcessImpl debugProcess = myEvaluationContext.getDebugProcess();
debugProcess.getManagerThread().invokeAndWait(new DebuggerCommandImpl() {
myEvaluationContext.getManagerThread().invokeAndWait(new DebuggerCommandImpl() {
@Override
public Priority getPriority() {
return Priority.HIGH;
@@ -501,11 +514,15 @@ public class JavaValue extends XNamedValue implements NodeDescriptorProvider, XV
@Nullable
@Override
public XInstanceEvaluator getInstanceEvaluator() {
final DebugProcessImpl process = myEvaluationContext.getDebugProcess();
return new XInstanceEvaluator() {
@Override
public void evaluate(@NotNull final XDebuggerEvaluator.XEvaluationCallback callback, @NotNull final XStackFrame frame) {
process.getManagerThread().schedule(new DebuggerCommandImpl() {
myEvaluationContext.getManagerThread().schedule(new DebuggerCommandImpl() {
@Override
protected void commandCancelled() {
callback.errorOccurred(DebuggerBundle.message("error.context.has.changed"));
}
@Override
protected void action() throws Exception {
ValueDescriptorImpl inspectDescriptor = myValueDescriptor;
@@ -126,6 +126,10 @@ public abstract class SuspendContextImpl extends XSuspendContext implements Susp
return myDebugProcess;
}
public DebugProcessImpl getDebugProcessNoAssert() {
return myDebugProcess;
}
@Override
public StackFrameProxyImpl getFrameProxy() {
assertNotResumed();
@@ -61,6 +61,10 @@ public final class EvaluationContextImpl implements EvaluationContext{
return getSuspendContext().getDebugProcess();
}
public DebuggerManagerThreadImpl getManagerThread() {
return getSuspendContext().getDebugProcessNoAssert().getManagerThread();
}
@Override
public Project getProject() {
DebugProcessImpl debugProcess = getDebugProcess();