diff --git a/platform/platform-resources-en/src/messages/ActionsBundle.properties b/platform/platform-resources-en/src/messages/ActionsBundle.properties index 8a9f652be733..a2012b22d11d 100644 --- a/platform/platform-resources-en/src/messages/ActionsBundle.properties +++ b/platform/platform-resources-en/src/messages/ActionsBundle.properties @@ -1874,6 +1874,10 @@ group.NewGroup1.text=New Group (1) action.NewModuleInGroup.text=Module action.ShelvedChanges.ShowHideDeleted.text=Show/Hide Applied Shelved Changes action.XDebugger.MuteBreakpoints.text=Mute Breakpoints +action.XDebugger.RemoveAllButThisBreakpoint.text=Remove All But This Breakpoint +action.XDebugger.RemoveAllButThisBreakpoint.description=Removes all breakpoints except on lines with carets +action.XDebugger.DisableAllButThisBreakpoint.text=Disable All But This Breakpoint +action.XDebugger.DisableAllButThisBreakpoint.description=Disables all breakpoints except on lines with carets action.ShelvedChanges.Restore.text=Restore Applied Shelved Change group.VcsToolbarActions.text=VCS Actions action.ChangesView.GroupBy.Repository.text=Repository diff --git a/platform/platform-resources/src/idea/XDebuggerActions.xml b/platform/platform-resources/src/idea/XDebuggerActions.xml index f16e93136aad..57d2a7ce4983 100644 --- a/platform/platform-resources/src/idea/XDebuggerActions.xml +++ b/platform/platform-resources/src/idea/XDebuggerActions.xml @@ -31,6 +31,12 @@ + + + + + + diff --git a/platform/xdebugger-impl/resources/META-INF/xdebugger.xml b/platform/xdebugger-impl/resources/META-INF/xdebugger.xml index 2f26262a6f8a..cc031629fce3 100644 --- a/platform/xdebugger-impl/resources/META-INF/xdebugger.xml +++ b/platform/xdebugger-impl/resources/META-INF/xdebugger.xml @@ -153,6 +153,10 @@ description="Enables frontend based actions in evaluation trees. Please, enable it only on the frontend side." key="debugger.frontend.tree.actions"/> + + UAST com.intellij.xdebugger.impl.codeinsight.ControlExceptionBreakpointIntentionAction diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/AllButThisBreakpointAction.kt b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/AllButThisBreakpointAction.kt new file mode 100644 index 000000000000..206a372d1d37 --- /dev/null +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/AllButThisBreakpointAction.kt @@ -0,0 +1,71 @@ +package com.intellij.xdebugger.impl.actions + +import com.intellij.openapi.actionSystem.ActionUpdateThread +import com.intellij.openapi.actionSystem.AnAction +import com.intellij.openapi.actionSystem.AnActionEvent +import com.intellij.openapi.actionSystem.CommonDataKeys +import com.intellij.openapi.editor.ex.EditorGutterComponentEx +import com.intellij.openapi.util.registry.Registry +import com.intellij.openapi.vfs.VirtualFile +import com.intellij.xdebugger.XDebuggerManager +import com.intellij.xdebugger.breakpoints.XBreakpoint +import com.intellij.xdebugger.breakpoints.XBreakpointManager + +abstract class AllButThisBreakpointAction : AnAction() { + override fun update(e: AnActionEvent) { + if (!Registry.`is`("debugger.remove.disable.actions", false)) { + e.presentation.isEnabledAndVisible = false + return + } + + val project = e.project ?: return + val (currentFile, caretLines) = getCurrentLines(e) ?: run { + e.presentation.isEnabledAndVisible = false + return + } + + val breakpointManager = XDebuggerManager.getInstance(project).breakpointManager + val breakpoints = breakpointManager.allBreakpoints + + e.presentation.isEnabledAndVisible = breakpoints.any { it.matches(currentFile, caretLines) } + } + + override fun actionPerformed(e: AnActionEvent) { + val project = e.project ?: return + val (currentFile, caretLines) = getCurrentLines(e) ?: return + + val breakpointManager = XDebuggerManager.getInstance(project).breakpointManager + val breakpoints = breakpointManager.allBreakpoints + + for (breakpoint in breakpoints) { + if (!breakpoint.matches(currentFile, caretLines)) { + performAction(breakpointManager, breakpoint) + } + } + } + + protected abstract fun performAction(breakpointManager: XBreakpointManager, breakpoint: XBreakpoint<*>) + + private fun getCurrentLines(e: AnActionEvent): Pair>? { + val editor = e.getData(CommonDataKeys.EDITOR) ?: return null + val caretLines = e.getData(EditorGutterComponentEx.LOGICAL_LINE_AT_CURSOR)?.let(::listOf) + ?: editor.caretModel.allCarets.map { it.logicalPosition.line } + val currentFile = editor.virtualFile + + if (caretLines.isEmpty()) return null + + return currentFile to caretLines + } + + private fun XBreakpoint<*>.matches(currentFile: VirtualFile, caretLines: List): Boolean { + val sourcePosition = this.sourcePosition + val breakpointFile = sourcePosition?.file + val breakpointLine = sourcePosition?.line + + return breakpointFile == currentFile && caretLines.contains(breakpointLine) + } + + override fun getActionUpdateThread(): ActionUpdateThread { + return ActionUpdateThread.BGT + } +} diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/DisableAllButThisBreakpointAction.kt b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/DisableAllButThisBreakpointAction.kt new file mode 100644 index 000000000000..2361cbd03fe5 --- /dev/null +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/DisableAllButThisBreakpointAction.kt @@ -0,0 +1,10 @@ +package com.intellij.xdebugger.impl.actions + +import com.intellij.xdebugger.breakpoints.XBreakpoint +import com.intellij.xdebugger.breakpoints.XBreakpointManager + +class DisableAllButThisBreakpointAction : AllButThisBreakpointAction() { + override fun performAction(breakpointManager: XBreakpointManager, breakpoint: XBreakpoint<*>) { + breakpoint.isEnabled = false + } +} \ No newline at end of file diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/RemoveAllButThisBreakpointAction.kt b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/RemoveAllButThisBreakpointAction.kt new file mode 100644 index 000000000000..f6c986894718 --- /dev/null +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/RemoveAllButThisBreakpointAction.kt @@ -0,0 +1,10 @@ +package com.intellij.xdebugger.impl.actions + +import com.intellij.xdebugger.breakpoints.XBreakpoint +import com.intellij.xdebugger.breakpoints.XBreakpointManager + +class RemoveAllButThisBreakpointAction : AllButThisBreakpointAction() { + override fun performAction(breakpointManager: XBreakpointManager, breakpoint: XBreakpoint<*>) { + breakpointManager.removeBreakpoint(breakpoint) + } +} \ No newline at end of file