diff --git a/java/debugger/impl/src/com/intellij/debugger/actions/AddSteppingFilterAction.java b/java/debugger/impl/src/com/intellij/debugger/actions/AddSteppingFilterAction.java index 397381ed5913..0d043f2c4ebe 100644 --- a/java/debugger/impl/src/com/intellij/debugger/actions/AddSteppingFilterAction.java +++ b/java/debugger/impl/src/com/intellij/debugger/actions/AddSteppingFilterAction.java @@ -1,4 +1,4 @@ -// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.debugger.actions; import com.intellij.debugger.JavaDebuggerBundle; @@ -28,7 +28,7 @@ public class AddSteppingFilterAction extends DebuggerAction { if (process == null) { return; } - final StackFrameProxyImpl proxy = PopFrameAction.getStackFrameProxy(e); + StackFrameProxyImpl proxy = getStackFrameProxy(e); process.getManagerThread().schedule(new DebuggerCommandImpl() { @Override protected void action() { @@ -51,7 +51,7 @@ public class AddSteppingFilterAction extends DebuggerAction { @Override public void update(@NotNull AnActionEvent e) { - e.getPresentation().setEnabledAndVisible(PopFrameAction.getStackFrameProxy(e) != null); + e.getPresentation().setEnabledAndVisible(getStackFrameProxy(e) != null); } @Override diff --git a/java/debugger/impl/src/com/intellij/debugger/actions/DebuggerAction.java b/java/debugger/impl/src/com/intellij/debugger/actions/DebuggerAction.java index e3867432bf8d..84533a802d26 100644 --- a/java/debugger/impl/src/com/intellij/debugger/actions/DebuggerAction.java +++ b/java/debugger/impl/src/com/intellij/debugger/actions/DebuggerAction.java @@ -9,10 +9,14 @@ package com.intellij.debugger.actions; import com.intellij.debugger.DebuggerManagerEx; import com.intellij.debugger.engine.JavaDebugProcess; +import com.intellij.debugger.engine.JavaStackFrame; import com.intellij.debugger.impl.DebuggerContextImpl; +import com.intellij.debugger.jdi.StackFrameProxyImpl; import com.intellij.debugger.ui.impl.DebuggerTreePanel; import com.intellij.debugger.ui.impl.watch.DebuggerTree; import com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl; +import com.intellij.debugger.ui.impl.watch.NodeDescriptorImpl; +import com.intellij.debugger.ui.impl.watch.StackFrameDescriptorImpl; import com.intellij.ide.DataManager; import com.intellij.openapi.Disposable; import com.intellij.openapi.actionSystem.AnAction; @@ -23,6 +27,7 @@ import com.intellij.openapi.project.Project; import com.intellij.ui.DoubleClickListener; import com.intellij.xdebugger.XDebugProcess; import com.intellij.xdebugger.XDebugSession; +import com.intellij.xdebugger.frame.XStackFrame; import com.intellij.xdebugger.impl.ui.DebuggerUIUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -132,4 +137,56 @@ public abstract class DebuggerAction extends AnAction { XDebugSession session = DebuggerUIUtil.getSession(e); return session != null && session.getDebugProcess() instanceof JavaDebugProcess; } + + static JavaStackFrame getStackFrame(AnActionEvent e) { + StackFrameDescriptorImpl descriptor = getSelectedStackFrameDescriptor(e); + if (descriptor != null) { + return new JavaStackFrame(descriptor, false); + } + return getSelectedStackFrame(e); + } + + 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(); + } + } + else { + JavaStackFrame stackFrame = getSelectedStackFrame(e); + if (stackFrame != null) { + return stackFrame.getStackFrameProxy(); + } + } + return null; + } + + @Nullable + private static StackFrameDescriptorImpl getSelectedStackFrameDescriptor(AnActionEvent e) { + DebuggerTreeNodeImpl selectedNode = getSelectedNode(e.getDataContext()); + if (selectedNode != null) { + NodeDescriptorImpl descriptor = selectedNode.getDescriptor(); + if (descriptor instanceof StackFrameDescriptorImpl) { + return (StackFrameDescriptorImpl)descriptor; + } + } + return null; + } + + @Nullable + private static JavaStackFrame getSelectedStackFrame(AnActionEvent e) { + Project project = e.getProject(); + if (project != null) { + XDebugSession session = DebuggerUIUtil.getSession(e); + if (session != null) { + XStackFrame frame = session.getCurrentStackFrame(); + if (frame instanceof JavaStackFrame) { + return ((JavaStackFrame)frame); + } + } + } + return null; + } } diff --git a/java/debugger/impl/src/com/intellij/debugger/actions/ForceEarlyReturnAction.java b/java/debugger/impl/src/com/intellij/debugger/actions/ForceEarlyReturnAction.java index 6dcb10620007..5a9bc7d13ed3 100644 --- a/java/debugger/impl/src/com/intellij/debugger/actions/ForceEarlyReturnAction.java +++ b/java/debugger/impl/src/com/intellij/debugger/actions/ForceEarlyReturnAction.java @@ -1,4 +1,4 @@ -// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.debugger.actions; @@ -15,7 +15,6 @@ import com.intellij.debugger.impl.DebuggerUtilsEx; import com.intellij.debugger.jdi.StackFrameProxyImpl; import com.intellij.debugger.jdi.ThreadReferenceProxyImpl; import com.intellij.idea.ActionsBundle; -import com.intellij.openapi.actionSystem.ActionPlaces; import com.intellij.openapi.actionSystem.ActionUpdateThread; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.application.ApplicationManager; @@ -28,6 +27,7 @@ import com.intellij.xdebugger.XExpression; import com.intellij.xdebugger.evaluation.XDebuggerEvaluator; import com.intellij.xdebugger.frame.XValue; import com.intellij.xdebugger.impl.evaluate.XExpressionDialog; +import com.intellij.xdebugger.impl.ui.DebuggerUIUtil; import com.sun.jdi.Method; import com.sun.jdi.Value; import org.jetbrains.annotations.NotNull; @@ -39,7 +39,7 @@ public class ForceEarlyReturnAction extends DebuggerAction { @Override public void actionPerformed(@NotNull AnActionEvent e) { final Project project = e.getProject(); - final JavaStackFrame stackFrame = PopFrameAction.getStackFrame(e); + final JavaStackFrame stackFrame = getStackFrame(e); if (stackFrame == null || project == null) { return; } @@ -170,17 +170,12 @@ public class ForceEarlyReturnAction extends DebuggerAction { public void update(@NotNull AnActionEvent e) { boolean enable = false; - JavaStackFrame stackFrame = PopFrameAction.getStackFrame(e); + JavaStackFrame stackFrame = getStackFrame(e); if (stackFrame != null && stackFrame.getDescriptor().getUiIndex() == 0) { enable = stackFrame.getStackFrameProxy().getVirtualMachine().canForceEarlyReturn(); } - if (ActionPlaces.isMainMenuOrActionSearch(e.getPlace()) || ActionPlaces.DEBUGGER_TOOLBAR.equals(e.getPlace())) { - e.getPresentation().setEnabled(enable); - } - else { - e.getPresentation().setVisible(enable); - } + DebuggerUIUtil.setActionEnabled(e, enable); } @Override diff --git a/java/debugger/impl/src/com/intellij/debugger/actions/JvmDropFrameActionHandler.java b/java/debugger/impl/src/com/intellij/debugger/actions/JvmDropFrameActionHandler.java index fa1cf051d6be..232cf0d393f1 100644 --- a/java/debugger/impl/src/com/intellij/debugger/actions/JvmDropFrameActionHandler.java +++ b/java/debugger/impl/src/com/intellij/debugger/actions/JvmDropFrameActionHandler.java @@ -10,7 +10,6 @@ import com.intellij.debugger.impl.DebuggerContextImpl; import com.intellij.debugger.impl.DebuggerSession; import com.intellij.debugger.jdi.StackFrameProxyImpl; import com.intellij.debugger.settings.DebuggerSettings; -import com.intellij.idea.ActionsBundle; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.diagnostic.Logger; @@ -23,7 +22,6 @@ import com.intellij.psi.*; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.ui.UIBundle; import com.intellij.util.containers.ContainerUtil; -import com.intellij.util.ui.UIUtil; import com.intellij.xdebugger.XDebuggerBundle; import com.intellij.xdebugger.evaluation.EvaluationMode; import com.intellij.xdebugger.evaluation.XDebuggerEvaluator; @@ -42,8 +40,6 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -import static com.intellij.debugger.actions.PopFrameAction.ACTION_NAME; - public class JvmDropFrameActionHandler implements XDropFrameHandler { private static final Logger LOG = Logger.getInstance(JvmDropFrameActionHandler.class); @@ -69,7 +65,7 @@ public class JvmDropFrameActionHandler implements XDropFrameHandler { try { myDebugSession.setSteppingThrough(stackFrame.getStackFrameProxy().threadProxy()); if (evaluateFinallyBlocks(project, - UIUtil.removeMnemonic(ActionsBundle.actionText(ACTION_NAME)), + XDebuggerBundle.message("xdebugger.reset.frame.title"), stackFrame, new XDebuggerEvaluator.XEvaluationCallback() { @Override @@ -80,7 +76,7 @@ public class JvmDropFrameActionHandler implements XDropFrameHandler { @Override public void errorOccurred(@NotNull final String errorMessage) { showError(project, JavaDebuggerBundle.message("error.executing.finally", errorMessage), - UIUtil.removeMnemonic(ActionsBundle.actionText(ACTION_NAME))); + XDebuggerBundle.message("xdebugger.reset.frame.title")); } })) { return; @@ -89,7 +85,7 @@ public class JvmDropFrameActionHandler implements XDropFrameHandler { } catch (NativeMethodException e2) { Messages.showMessageDialog(project, JavaDebuggerBundle.message("error.native.method.exception"), - UIUtil.removeMnemonic(ActionsBundle.actionText(ACTION_NAME)), Messages.getErrorIcon()); + XDebuggerBundle.message("xdebugger.reset.frame.title"), Messages.getErrorIcon()); } catch (InvalidStackFrameException | VMDisconnectedException ignored) { } @@ -187,7 +183,7 @@ public class JvmDropFrameActionHandler implements XDropFrameHandler { } else { Messages.showMessageDialog(project, XDebuggerBundle.message("xdebugger.evaluate.stack.frame.has.not.evaluator"), - UIUtil.removeMnemonic(ActionsBundle.actionText(ACTION_NAME)), + XDebuggerBundle.message("xdebugger.reset.frame.title"), Messages.getErrorIcon()); } } diff --git a/java/debugger/impl/src/com/intellij/debugger/actions/PopFrameAction.java b/java/debugger/impl/src/com/intellij/debugger/actions/PopFrameAction.java deleted file mode 100644 index 6bc157347856..000000000000 --- a/java/debugger/impl/src/com/intellij/debugger/actions/PopFrameAction.java +++ /dev/null @@ -1,129 +0,0 @@ -// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. - -/* - * @author Eugene Zhuravlev - */ -package com.intellij.debugger.actions; - -import com.intellij.debugger.engine.JavaStackFrame; -import com.intellij.debugger.jdi.StackFrameProxyImpl; -import com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl; -import com.intellij.debugger.ui.impl.watch.NodeDescriptorImpl; -import com.intellij.debugger.ui.impl.watch.StackFrameDescriptorImpl; -import com.intellij.openapi.actionSystem.ActionPlaces; -import com.intellij.openapi.actionSystem.ActionUpdateThread; -import com.intellij.openapi.actionSystem.AnActionEvent; -import com.intellij.openapi.project.DumbAware; -import com.intellij.openapi.project.Project; -import com.intellij.xdebugger.XDebugProcess; -import com.intellij.xdebugger.XDebugSession; -import com.intellij.xdebugger.frame.XDropFrameHandler; -import com.intellij.xdebugger.frame.XStackFrame; -import com.intellij.xdebugger.impl.ui.DebuggerUIUtil; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.Optional; - -public class PopFrameAction extends DebuggerAction implements DumbAware { - @NonNls public static final String ACTION_NAME = "Debugger.PopFrame"; - - @Override - public void actionPerformed(@NotNull AnActionEvent e) { - final JavaStackFrame stackFrame = getStackFrame(e); - if (stackFrame == null || stackFrame.getStackFrameProxy().isBottom()) { - return; - } - final XDropFrameHandler handler = getDropFrameHandler(e); - final JavaStackFrame frame = getSelectedStackFrame(e); - if (frame != null && handler != null) { - handler.drop(frame); - } - } - - static JavaStackFrame getStackFrame(AnActionEvent e) { - StackFrameDescriptorImpl descriptor = getSelectedStackFrameDescriptor(e); - if (descriptor != null) { - return new JavaStackFrame(descriptor, false); - } - return getSelectedStackFrame(e); - } - - 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(); - } - } - else { - JavaStackFrame stackFrame = getSelectedStackFrame(e); - if (stackFrame != null) { - return stackFrame.getStackFrameProxy(); - } - } - return null; - } - - @Nullable - private static StackFrameDescriptorImpl getSelectedStackFrameDescriptor(AnActionEvent e) { - DebuggerTreeNodeImpl selectedNode = getSelectedNode(e.getDataContext()); - if (selectedNode != null) { - NodeDescriptorImpl descriptor = selectedNode.getDescriptor(); - if (descriptor instanceof StackFrameDescriptorImpl) { - return (StackFrameDescriptorImpl)descriptor; - } - } - return null; - } - - @Nullable - private static JavaStackFrame getSelectedStackFrame(AnActionEvent e) { - Project project = e.getProject(); - if (project != null) { - XDebugSession session = DebuggerUIUtil.getSession(e); - if (session != null) { - XStackFrame frame = session.getCurrentStackFrame(); - if (frame instanceof JavaStackFrame) { - return ((JavaStackFrame)frame); - } - } - } - return null; - } - - @Override - public void update(@NotNull AnActionEvent e) { - boolean enable = false; - - var xStackFrame = getSelectedStackFrame(e); - var xDropFrameHandler = getDropFrameHandler(e); - if (xStackFrame != null && xDropFrameHandler != null) { - enable = xDropFrameHandler.canDrop(xStackFrame); - } - - if ((ActionPlaces.isMainMenuOrActionSearch(e.getPlace()) || ActionPlaces.DEBUGGER_TOOLBAR.equals(e.getPlace())) - && xDropFrameHandler != null) { - e.getPresentation().setEnabled(enable); - } - else { - e.getPresentation().setVisible(enable); - } - } - - @Override - public @NotNull ActionUpdateThread getActionUpdateThread() { - return ActionUpdateThread.BGT; - } - - @Nullable - private static XDropFrameHandler getDropFrameHandler(@NotNull AnActionEvent e) { - var xSession = DebuggerUIUtil.getSession(e); - return Optional.ofNullable(xSession) - .map(XDebugSession::getDebugProcess) - .map(XDebugProcess::getDropFrameHandler) - .orElse(null); - } -} diff --git a/java/debugger/impl/src/com/intellij/debugger/actions/ThrowExceptionAction.java b/java/debugger/impl/src/com/intellij/debugger/actions/ThrowExceptionAction.java index 58ef6edcbb63..e0ec551fdce4 100644 --- a/java/debugger/impl/src/com/intellij/debugger/actions/ThrowExceptionAction.java +++ b/java/debugger/impl/src/com/intellij/debugger/actions/ThrowExceptionAction.java @@ -1,4 +1,4 @@ -// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.debugger.actions; @@ -13,7 +13,6 @@ import com.intellij.debugger.impl.DebuggerContextImpl; import com.intellij.debugger.jdi.StackFrameProxyImpl; import com.intellij.debugger.jdi.ThreadReferenceProxyImpl; import com.intellij.idea.ActionsBundle; -import com.intellij.openapi.actionSystem.ActionPlaces; import com.intellij.openapi.actionSystem.ActionUpdateThread; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.application.ApplicationManager; @@ -26,6 +25,7 @@ import com.intellij.xdebugger.XExpression; import com.intellij.xdebugger.evaluation.XDebuggerEvaluator; import com.intellij.xdebugger.frame.XValue; import com.intellij.xdebugger.impl.evaluate.XExpressionDialog; +import com.intellij.xdebugger.impl.ui.DebuggerUIUtil; import com.sun.jdi.ObjectReference; import com.sun.jdi.Value; import org.jetbrains.annotations.NotNull; @@ -37,7 +37,7 @@ public class ThrowExceptionAction extends DebuggerAction { @Override public void actionPerformed(@NotNull AnActionEvent e) { final Project project = e.getProject(); - final JavaStackFrame stackFrame = PopFrameAction.getStackFrame(e); + final JavaStackFrame stackFrame = getStackFrame(e); if (stackFrame == null || project == null) { return; } @@ -123,15 +123,8 @@ public class ThrowExceptionAction extends DebuggerAction { @Override public void update(@NotNull AnActionEvent e) { - JavaStackFrame stackFrame = PopFrameAction.getStackFrame(e); - boolean enable = stackFrame != null && stackFrame.getDescriptor().getUiIndex() == 0; - - if (ActionPlaces.isMainMenuOrActionSearch(e.getPlace()) || ActionPlaces.DEBUGGER_TOOLBAR.equals(e.getPlace())) { - e.getPresentation().setEnabled(enable); - } - else { - e.getPresentation().setVisible(enable); - } + JavaStackFrame stackFrame = getStackFrame(e); + DebuggerUIUtil.setActionEnabled(e, stackFrame != null && stackFrame.getDescriptor().getUiIndex() == 0); } @Override diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessImpl.java b/java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessImpl.java index b30117ae5ac6..ce624c12bdaa 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessImpl.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessImpl.java @@ -6,7 +6,6 @@ import com.intellij.ProjectTopics; import com.intellij.ReviseWhenPortedToJDK; import com.intellij.debugger.*; import com.intellij.debugger.actions.DebuggerAction; -import com.intellij.debugger.actions.PopFrameAction; import com.intellij.debugger.engine.evaluation.*; import com.intellij.debugger.engine.events.DebuggerCommandImpl; import com.intellij.debugger.engine.events.DebuggerContextCommandImpl; @@ -64,6 +63,7 @@ import com.intellij.util.containers.ContainerUtil; import com.intellij.util.lang.JavaVersion; import com.intellij.util.ui.UIUtil; import com.intellij.xdebugger.XDebugSession; +import com.intellij.xdebugger.XDebuggerBundle; import com.intellij.xdebugger.XSourcePosition; import com.intellij.xdebugger.impl.XDebugSessionImpl; import com.intellij.xdebugger.impl.XDebuggerManagerImpl; @@ -2004,7 +2004,7 @@ public abstract class DebugProcessImpl extends UserDataHolderBase implements Deb if (myStackFrame.isBottom()) { DebuggerInvocationUtil.swingInvokeLater(myProject, () -> Messages.showMessageDialog(myProject, JavaDebuggerBundle - .message("error.pop.bottom.stackframe"), ActionsBundle.actionText(PopFrameAction.ACTION_NAME), Messages.getErrorIcon())); + .message("error.pop.bottom.stackframe"), XDebuggerBundle.message("xdebugger.reset.frame.title"), Messages.getErrorIcon())); return; } @@ -2013,10 +2013,9 @@ public abstract class DebugProcessImpl extends UserDataHolderBase implements Deb getSuspendManager().popFrame(suspendContext); } catch (final EvaluateException e) { - DebuggerInvocationUtil.swingInvokeLater(myProject, - () -> Messages.showMessageDialog(myProject, JavaDebuggerBundle - .message("error.pop.stackframe", e.getLocalizedMessage()), ActionsBundle.actionText( - PopFrameAction.ACTION_NAME), Messages.getErrorIcon())); + DebuggerInvocationUtil.swingInvokeLater(myProject, () -> + Messages.showMessageDialog(myProject, JavaDebuggerBundle.message("error.pop.stackframe", e.getLocalizedMessage()), + XDebuggerBundle.message("xdebugger.reset.frame.title"), Messages.getErrorIcon())); LOG.info(e); } } diff --git a/platform/platform-resources-en/src/messages/ActionsBundle.properties b/platform/platform-resources-en/src/messages/ActionsBundle.properties index 99d26bf62336..86e5687b99f9 100644 --- a/platform/platform-resources-en/src/messages/ActionsBundle.properties +++ b/platform/platform-resources-en/src/messages/ActionsBundle.properties @@ -904,8 +904,8 @@ action.RunToCursor.text=Run to _Cursor action.RunToCursor.description=Run to the line where the caret is action.ForceRunToCursor.text=Force Run to Cur_sor action.ForceRunToCursor.description=Run to the line where the caret is, ignoring any breakpoints -action.Debugger.PopFrame.text=Reset _Frame -action.Debugger.PopFrame.description=Moves execution point back to the method call dropping current method frames from the stack +action.ResetFrame.text=Reset _Frame +action.ResetFrame.description=Moves execution point back to the method call dropping current method frames from the stack action.Debugger.ForceEarlyReturn.text=Force Return action.Debugger.ForceEarlyReturn.description=Force a method to return before it reaches a return statement action.Debugger.ThrowException.text=Throw Exception diff --git a/platform/platform-resources/src/idea/LangActions.xml b/platform/platform-resources/src/idea/LangActions.xml index b5917a552626..86be435d033b 100644 --- a/platform/platform-resources/src/idea/LangActions.xml +++ b/platform/platform-resources/src/idea/LangActions.xml @@ -1087,6 +1087,7 @@ + @@ -1200,6 +1201,7 @@ + @@ -1235,6 +1237,7 @@ + diff --git a/platform/xdebugger-api/resources/messages/XDebuggerBundle.properties b/platform/xdebugger-api/resources/messages/XDebuggerBundle.properties index d23efdb15c8d..0483bb1c560f 100644 --- a/platform/xdebugger-api/resources/messages/XDebuggerBundle.properties +++ b/platform/xdebugger-api/resources/messages/XDebuggerBundle.properties @@ -111,6 +111,7 @@ button.text.expression.mode=Expression &Mode xdebugger.label.text.code.fragment=Code fragment: xdebugger.evaluate.result=result xdebugger.evaluate.stack.frame.has.not.evaluator=Cannot evaluate, current stack frame doesn't support evaluation +xdebugger.reset.frame.title=Reset Frame xdebugger.popup.value.tree.set.root.action.tooltip=Set As Root diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/ResetFrameAction.kt b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/ResetFrameAction.kt new file mode 100644 index 000000000000..38cc24d02503 --- /dev/null +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/ResetFrameAction.kt @@ -0,0 +1,35 @@ +// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +package com.intellij.xdebugger.impl.actions + +import com.intellij.openapi.actionSystem.ActionUpdateThread +import com.intellij.openapi.actionSystem.AnActionEvent +import com.intellij.openapi.project.DumbAwareAction +import com.intellij.xdebugger.frame.XDropFrameHandler +import com.intellij.xdebugger.frame.XStackFrame +import com.intellij.xdebugger.impl.ui.DebuggerUIUtil + +class ResetFrameAction : DumbAwareAction() { + override fun actionPerformed(e: AnActionEvent) { + withHandler(e, true) { handler, stackFrame -> handler.drop(stackFrame) } + } + + override fun update(e: AnActionEvent) { + DebuggerUIUtil.setActionEnabled(e, withHandler(e, false) { handler, stackFrame -> handler.canDrop(stackFrame) }) + } + + override fun getActionUpdateThread() = ActionUpdateThread.BGT + + private fun withHandler(e: AnActionEvent, default: T, action: (XDropFrameHandler, XStackFrame) -> T): T { + val session = DebuggerUIUtil.getSession(e) + if (session != null) { + val dropFrameHandler = session.debugProcess.dropFrameHandler + if (dropFrameHandler != null) { + val currentFrame = session.currentStackFrame + if (currentFrame != null) { + return action(dropFrameHandler, currentFrame) + } + } + } + return default + } +} \ No newline at end of file diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/DebuggerUIUtil.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/DebuggerUIUtil.java index 60ac7efd1086..82fcf3e7a0a2 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/DebuggerUIUtil.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/DebuggerUIUtil.java @@ -1,10 +1,11 @@ -// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.xdebugger.impl.ui; import com.intellij.codeInsight.hint.HintUtil; import com.intellij.ide.nls.NlsMessages; import com.intellij.openapi.Disposable; import com.intellij.openapi.actionSystem.ActionManager; +import com.intellij.openapi.actionSystem.ActionPlaces; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.application.ApplicationManager; @@ -570,4 +571,14 @@ public final class DebuggerUIUtil { editor.getContentComponent().repaint(); } } + + public static void setActionEnabled(AnActionEvent e, boolean enable) { + String place = e.getPlace(); + if (ActionPlaces.isMainMenuOrActionSearch(place) || ActionPlaces.DEBUGGER_TOOLBAR.equals(place)) { + e.getPresentation().setEnabled(enable); + } + else { + e.getPresentation().setVisible(enable); + } + } } \ No newline at end of file diff --git a/resources/src/idea/JavaActions.xml b/resources/src/idea/JavaActions.xml index e4c7e2c9083c..d6639773e15c 100644 --- a/resources/src/idea/JavaActions.xml +++ b/resources/src/idea/JavaActions.xml @@ -391,13 +391,6 @@ - - - - - - - @@ -471,7 +464,6 @@ - @@ -492,13 +484,13 @@ - - + + - + @@ -616,7 +608,7 @@ - +