more correct add stepping filter availability
authorEgor.Ushakov <egor.ushakov@jetbrains.com>
Thu, 30 Jul 2015 16:54:12 +0000 (19:54 +0300)
committerEgor.Ushakov <egor.ushakov@jetbrains.com>
Thu, 30 Jul 2015 16:55:33 +0000 (19:55 +0300)
java/debugger/impl/src/com/intellij/debugger/actions/AddSteppingFilterAction.java
java/debugger/impl/src/com/intellij/debugger/actions/PopFrameAction.java

index 4b549a7a4bdd832825c31a6e8869f245a6f5a0d0..3506416896688f74ae58e8c35130e4e5f62b01a9 100644 (file)
@@ -25,9 +25,6 @@ import com.intellij.debugger.engine.events.DebuggerCommandImpl;
 import com.intellij.debugger.impl.DebuggerContextImpl;
 import com.intellij.debugger.jdi.StackFrameProxyImpl;
 import com.intellij.debugger.settings.DebuggerSettings;
-import com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl;
-import com.intellij.debugger.ui.impl.watch.StackFrameDescriptorImpl;
-import com.intellij.debugger.ui.tree.ThreadDescriptor;
 import com.intellij.openapi.actionSystem.AnActionEvent;
 import com.intellij.openapi.actionSystem.CommonDataKeys;
 import com.intellij.openapi.application.ApplicationManager;
@@ -45,10 +42,10 @@ public class AddSteppingFilterAction extends DebuggerAction {
     if (process == null) {
       return;
     }
-    final StackFrameDescriptorImpl descriptor = PopFrameAction.getSelectedStackFrameDescriptor(e);
+    final StackFrameProxyImpl proxy = PopFrameAction.getStackFrameProxy(e);
     process.getManagerThread().schedule(new DebuggerCommandImpl() {
       protected void action() throws Exception {
-        final String name = getClassName(descriptor != null ? descriptor.getFrameProxy() : debuggerContext.getFrameProxy());
+        final String name = getClassName(proxy != null ? proxy : debuggerContext.getFrameProxy());
         if (name == null) {
           return;
         }
@@ -69,13 +66,7 @@ public class AddSteppingFilterAction extends DebuggerAction {
   }
 
   public void update(AnActionEvent e) {
-    DebuggerTreeNodeImpl selectedNode = getSelectedNode(e.getDataContext());
-    if (selectedNode != null && selectedNode.getDescriptor() instanceof ThreadDescriptor) {
-      e.getPresentation().setEnabledAndVisible(false);
-    }
-    else {
-      e.getPresentation().setEnabledAndVisible(true);
-    }
+    e.getPresentation().setEnabledAndVisible(PopFrameAction.getStackFrameProxy(e) != null);
   }
 
   private static String getClassName(StackFrameProxyImpl stackFrameProxy) {
index a6c178e6c29dbd89edef04bdc1c64e4500190725..5b4048129cba2c87d2fd9efde70f3689ad26a94b 100644 (file)
@@ -222,16 +222,22 @@ public class PopFrameAction extends DebuggerAction {
       }
       return new JavaStackFrame(descriptor, false);
     }
-    return getSelectedStackFrame(e);
+    JavaStackFrame frame = getSelectedStackFrame(e);
+    if (frame != null) {
+      StackFrameProxyImpl proxy = frame.getStackFrameProxy();
+      if (proxy == null || proxy.isBottom()) return null;
+      return frame;
+    }
+    return null;
   }
 
-  private static StackFrameProxyImpl getStackFrameProxy(AnActionEvent e) {
-    StackFrameDescriptorImpl descriptor = getSelectedStackFrameDescriptor(e);
-    if (descriptor != null) {
-      if (descriptor.getFrameProxy().isBottom()) {
-        return null;
+  static StackFrameProxyImpl getStackFrameProxy(AnActionEvent e) {
+    DebuggerTreeNodeImpl node = getSelectedNode(e.getDataContext());
+    if (node != null) {
+      NodeDescriptorImpl descriptor = node.getDescriptor();
+      if (descriptor instanceof StackFrameDescriptorImpl) {
+        return ((StackFrameDescriptorImpl)descriptor).getFrameProxy();
       }
-      return descriptor.getFrameProxy();
     }
     else {
       JavaStackFrame stackFrame = getSelectedStackFrame(e);
@@ -243,7 +249,7 @@ public class PopFrameAction extends DebuggerAction {
   }
 
   @Nullable
-  static StackFrameDescriptorImpl getSelectedStackFrameDescriptor(AnActionEvent e) {
+  private static StackFrameDescriptorImpl getSelectedStackFrameDescriptor(AnActionEvent e) {
     DebuggerTreeNodeImpl selectedNode = getSelectedNode(e.getDataContext());
     if(selectedNode != null) {
       NodeDescriptorImpl descriptor = selectedNode.getDescriptor();
@@ -268,8 +274,7 @@ public class PopFrameAction extends DebuggerAction {
       if (session != null) {
         XStackFrame frame = session.getCurrentStackFrame();
         if (frame instanceof JavaStackFrame) {
-          StackFrameProxyImpl proxy = ((JavaStackFrame)frame).getStackFrameProxy();
-          return !proxy.isBottom() ? ((JavaStackFrame)frame) : null;
+          return ((JavaStackFrame)frame);
         }
       }
     }
@@ -301,7 +306,7 @@ public class PopFrameAction extends DebuggerAction {
     boolean enable = false;
 
     StackFrameProxyImpl proxy = getStackFrameProxy(e);
-    if (proxy != null && isAtBreakpoint(e)) {
+    if (proxy != null && !proxy.isBottom() && isAtBreakpoint(e)) {
       enable = proxy.getVirtualMachine().canPopFrames();
     }