mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-15 02:59:33 +07:00
[debugger] IJPL-175036 IDEA-367772 Add Remove/disable all but these breakpoints features
GitOrigin-RevId: 67dcbe2b23767a0d05b1b9f5b0b693b7d1946ef3
This commit is contained in:
committed by
intellij-monorepo-bot
parent
70d91fc7bb
commit
360c6ee55f
@@ -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
|
||||
|
||||
@@ -31,6 +31,12 @@
|
||||
<action id="XDebugger.RemoveAllWatches" class="com.intellij.xdebugger.impl.frame.actions.XRemoveAllWatchesAction"/>
|
||||
<action id="XDebugger.MuteBreakpoints" class="com.intellij.xdebugger.impl.actions.MuteBreakpointAction"
|
||||
icon="AllIcons.Debugger.MuteBreakpoints"/>
|
||||
<action id="XDebugger.RemoveAllButThisBreakpoint" class="com.intellij.xdebugger.impl.actions.RemoveAllButThisBreakpointAction">
|
||||
<add-to-group group-id="EditorGutterPopupMenu" anchor="last"/>
|
||||
</action>
|
||||
<action id="XDebugger.DisableAllButThisBreakpoint" class="com.intellij.xdebugger.impl.actions.DisableAllButThisBreakpointAction">
|
||||
<add-to-group group-id="EditorGutterPopupMenu" anchor="last"/>
|
||||
</action>
|
||||
<action id="XDebugger.ToggleSortValues" class="com.intellij.xdebugger.impl.ui.tree.actions.SortValuesToggleAction" icon="AllIcons.ObjectBrowser.Sorted"/>
|
||||
<action id="Debugger.MarkObject" class="com.intellij.xdebugger.impl.actions.MarkObjectAction" use-shortcut-of="ToggleBookmark"/>
|
||||
<action id="Debugger.FocusOnBreakpoint" class="com.intellij.xdebugger.impl.actions.FocusOnBreakpointAction"/>
|
||||
|
||||
@@ -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"/>
|
||||
|
||||
<registryKey defaultValue="false"
|
||||
description="Enables remove/disable all but this breakpoint actions"
|
||||
key="debugger.remove.disable.actions"/>
|
||||
|
||||
<intentionAction>
|
||||
<language>UAST</language>
|
||||
<className>com.intellij.xdebugger.impl.codeinsight.ControlExceptionBreakpointIntentionAction</className>
|
||||
|
||||
@@ -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<VirtualFile, List<Int>>? {
|
||||
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<Int>): 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
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user