IDEA-131931 Debugger: Throwable at SuspendContextImpl.getDebugProcess() on opening...
authorEgor.Ushakov <egor.ushakov@jetbrains.com>
Thu, 30 Oct 2014 18:14:35 +0000 (21:14 +0300)
committerEgor.Ushakov <egor.ushakov@jetbrains.com>
Thu, 30 Oct 2014 18:16:03 +0000 (21:16 +0300)
java/debugger/impl/src/com/intellij/debugger/engine/JavaValue.java
java/debugger/impl/src/com/intellij/debugger/engine/SuspendContextImpl.java
java/debugger/impl/src/com/intellij/debugger/engine/evaluation/EvaluationContextImpl.java

index 6ea0b626cd00b75df1842d0b91c189d798e18fc9..a6b017dcfce16fa645317f86c50174984985914e 100644 (file)
@@ -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;
index 00aae83904ce59ebc8ceee1c8d6f1cf9f56db3cf..76c0484e83bc439bd4eaddd1305ea667a265547e 100644 (file)
@@ -126,6 +126,10 @@ public abstract class SuspendContextImpl extends XSuspendContext implements Susp
     return myDebugProcess;
   }
 
+  public DebugProcessImpl getDebugProcessNoAssert() {
+    return myDebugProcess;
+  }
+
   @Override
   public StackFrameProxyImpl getFrameProxy() {
     assertNotResumed();
index 759d92fd57a80d0af815d018cae3d7a087e5aafc..252aca73cdc03323dd7c2a23400790807e08b45d 100644 (file)
@@ -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();