diff --git a/platform/xdebugger-impl/frontend/src/com/intellij/platform/debugger/impl/frontend/FrontendXBreakpointManager.kt b/platform/xdebugger-impl/frontend/src/com/intellij/platform/debugger/impl/frontend/FrontendXBreakpointManager.kt index 33aee7a2380e..1805a68dec92 100644 --- a/platform/xdebugger-impl/frontend/src/com/intellij/platform/debugger/impl/frontend/FrontendXBreakpointManager.kt +++ b/platform/xdebugger-impl/frontend/src/com/intellij/platform/debugger/impl/frontend/FrontendXBreakpointManager.kt @@ -5,6 +5,7 @@ import com.intellij.concurrency.ConcurrentCollectionFactory import com.intellij.openapi.Disposable import com.intellij.openapi.application.EDT import com.intellij.openapi.application.readAction +import com.intellij.openapi.diagnostic.logger import com.intellij.openapi.editor.Editor import com.intellij.openapi.project.Project import com.intellij.openapi.util.Disposer @@ -24,6 +25,8 @@ import org.jetbrains.annotations.VisibleForTesting import java.util.concurrent.ConcurrentHashMap import java.util.concurrent.ConcurrentMap +private val log = logger() + @ApiStatus.Internal @VisibleForTesting class FrontendXBreakpointManager(private val project: Project, private val cs: CoroutineScope) : XBreakpointManagerProxy { @@ -67,6 +70,7 @@ class FrontendXBreakpointManager(private val project: Project, private val cs: C addBreakpoint(event.breakpointDto) } is XBreakpointEvent.BreakpointRemoved -> { + log.info("Breakpoint removal request from backend: ${event.breakpointId}") removeBreakpointLocally(event.breakpointId) // breakpointRemoved event happened on the server, so we can remove id from the frontend breakpointIdsRemovedLocally.remove(event.breakpointId) @@ -79,10 +83,12 @@ class FrontendXBreakpointManager(private val project: Project, private val cs: C override fun addBreakpoint(breakpointDto: XBreakpointDto): XBreakpointProxy? { if (breakpointDto.id in breakpointIdsRemovedLocally) { // don't add breakpoints if it was already removed locally + log.info("Breakpoint creation skipped for ${breakpointDto.id}, because it was removed locally") return null } val currentBreakpoint = breakpoints[breakpointDto.id] if (currentBreakpoint != null) { + log.info("Breakpoint creation skipped for ${breakpointDto.id}, because it already exists") return currentBreakpoint } val type = FrontendXBreakpointTypesManager.getInstance(project).getTypeById(breakpointDto.typeId) ?: return null @@ -95,11 +101,13 @@ class FrontendXBreakpointManager(private val project: Project, private val cs: C val previousBreakpoint = breakpoints.putIfAbsent(breakpointDto.id, newBreakpoint) if (previousBreakpoint != null) { newBreakpoint.dispose() + log.info("Breakpoint creation skipped for ${breakpointDto.id}, because it is already created") return previousBreakpoint } if (newBreakpoint is XLineBreakpointProxy) { lineBreakpointManager.registerBreakpoint(newBreakpoint, true) } + log.info("Breakpoint created for ${breakpointDto.id}") breakpointsChanged.tryEmit(Unit) return newBreakpoint } @@ -166,6 +174,12 @@ class FrontendXBreakpointManager(private val project: Project, private val cs: C private fun removeBreakpointLocally(breakpointId: XBreakpointId) { val removedBreakpoint = breakpoints.remove(breakpointId) removedBreakpoint?.dispose() + if (removedBreakpoint == null) { + log.info("Breakpoint removal has no effect for $breakpointId, because it doesn't exist locally") + } + else { + log.info("Breakpoint removed for $breakpointId") + } if (removedBreakpoint is XLineBreakpointProxy) { lineBreakpointManager.unregisterBreakpoint(removedBreakpoint) } @@ -225,6 +239,7 @@ class FrontendXBreakpointManager(private val project: Project, private val cs: C } override fun removeBreakpoint(breakpoint: XBreakpointProxy) { + log.info("Breakpoint removal request from frontend: ${breakpoint.id}") removeBreakpointLocally(breakpoint.id) breakpointsChanged.tryEmit(Unit) cs.launch { diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XBreakpointBase.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XBreakpointBase.java index 8c57986033fc..0d142e1c1a57 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XBreakpointBase.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XBreakpointBase.java @@ -363,7 +363,7 @@ public class XBreakpointBase, P extends XBreakpointP @Override public String toString() { - return "XBreakpointBase(type=" + myType + ")"; + return "XBreakpointBase(id = " + myId + ", type=" + myType + ")"; } protected List getAdditionalPopupMenuActions(XDebugSession session) { diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XBreakpointManagerImpl.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XBreakpointManagerImpl.java index eced91594cde..cda65e9439c4 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XBreakpointManagerImpl.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XBreakpointManagerImpl.java @@ -206,8 +206,8 @@ public final class XBreakpointManagerImpl implements XBreakpointManager { } } myAllBreakpoints.add(breakpoint); - if (breakpoint instanceof XLineBreakpointImpl) { - myLineBreakpointManager.registerBreakpoint(asProxy((XLineBreakpointImpl)breakpoint), initUI); + if (breakpoint instanceof XLineBreakpointImpl lineBreakpoint) { + myLineBreakpointManager.registerBreakpoint(asProxy(lineBreakpoint), initUI); } }); sendBreakpointEvent(type, listener -> listener.breakpointAdded(breakpoint)); @@ -230,8 +230,8 @@ public final class XBreakpointManagerImpl implements XBreakpointManager { public void fireBreakpointChanged(XBreakpointBase breakpoint) { if (isRegistered(breakpoint)) { - if (breakpoint instanceof XLineBreakpointImpl) { - myLineBreakpointManager.breakpointChanged(asProxy((XLineBreakpointImpl)breakpoint)); + if (breakpoint instanceof XLineBreakpointImpl lineBreakpoint) { + myLineBreakpointManager.breakpointChanged(asProxy(lineBreakpoint)); } sendBreakpointEvent(breakpoint.getType(), listener -> listener.breakpointChanged(breakpoint)); } diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XLineBreakpointImpl.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XLineBreakpointImpl.java index 776bc94fbd7d..3d44bdf10d76 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XLineBreakpointImpl.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XLineBreakpointImpl.java @@ -199,6 +199,6 @@ public final class XLineBreakpointImpl

extends @Override public String toString() { - return "XLineBreakpointImpl(" + myType.getId() + " at " + getShortFilePath() + ":" + getLine() + ")"; + return "XLineBreakpointImpl(id = " + getBreakpointId() + ", " + myType.getId() + " at " + getShortFilePath() + ":" + getLine() + ")"; } } diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XLineBreakpointManager.kt b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XLineBreakpointManager.kt index c1ede9fda0cb..358677614e23 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XLineBreakpointManager.kt +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XLineBreakpointManager.kt @@ -51,12 +51,15 @@ import com.intellij.xdebugger.impl.actions.ToggleLineBreakpointAction import com.intellij.xdebugger.impl.breakpoints.InlineBreakpointInlayManager.Companion.getInstance import com.intellij.xdebugger.impl.frame.XDebugManagerProxy import com.intellij.xdebugger.impl.frame.XDebugSessionProxy +import fleet.util.logging.logger import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.cancel import org.jetbrains.annotations.ApiStatus.Internal import org.jetbrains.annotations.TestOnly import java.awt.event.MouseEvent +private val log = logger() + @Internal class XLineBreakpointManager(private val project: Project, coroutineScope: CoroutineScope, private val isEnabled: Boolean) { private val cs = coroutineScope.childScope("XLineBreakpointManager") @@ -140,10 +143,12 @@ class XLineBreakpointManager(private val project: Project, coroutineScope: Corou if (initUI) { updateBreakpointNow(breakpoint) } + log.info("Register line breakpoint ${breakpoint.id} ${breakpoint.javaClass.simpleName}") myBreakpoints.putValue(breakpoint.getFile()?.url ?: breakpoint.getFileUrl(), breakpoint) } fun unregisterBreakpoint(breakpoint: XLineBreakpointProxy) { + log.info("Unregister line breakpoint ${breakpoint.id} ${breakpoint.javaClass.simpleName}") myBreakpoints.remove(breakpoint.getFile()?.url ?: breakpoint.getFileUrl(), breakpoint) } @@ -225,6 +230,7 @@ class XLineBreakpointManager(private val project: Project, coroutineScope: Corou } } + @Deprecated("Use queueBreakpointUpdateCallback(XLightLineBreakpointProxy, Runnable)") fun queueBreakpointUpdateCallback(breakpoint: XLineBreakpointImpl<*>?, callback: Runnable) { breakpointUpdateQueue.queue(object : Update(breakpoint) { override fun run() {