mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[rd debugger] IJPL-190337 Add logs for breakpoint registration and removal on frontend
GitOrigin-RevId: b10f281e2c1e16a60e6b4fc24c4d79ae7a318878
This commit is contained in:
committed by
intellij-monorepo-bot
parent
e11adb5e2d
commit
9f9d32631b
+15
@@ -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<FrontendXBreakpointManager>()
|
||||
|
||||
@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 {
|
||||
|
||||
+1
-1
@@ -363,7 +363,7 @@ public class XBreakpointBase<Self extends XBreakpoint<P>, P extends XBreakpointP
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "XBreakpointBase(type=" + myType + ")";
|
||||
return "XBreakpointBase(id = " + myId + ", type=" + myType + ")";
|
||||
}
|
||||
|
||||
protected List<? extends AnAction> getAdditionalPopupMenuActions(XDebugSession session) {
|
||||
|
||||
+4
-4
@@ -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));
|
||||
}
|
||||
|
||||
+1
-1
@@ -199,6 +199,6 @@ public final class XLineBreakpointImpl<P extends XBreakpointProperties> extends
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "XLineBreakpointImpl(" + myType.getId() + " at " + getShortFilePath() + ":" + getLine() + ")";
|
||||
return "XLineBreakpointImpl(id = " + getBreakpointId() + ", " + myType.getId() + " at " + getShortFilePath() + ":" + getLine() + ")";
|
||||
}
|
||||
}
|
||||
|
||||
+6
@@ -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<XLineBreakpointManager>()
|
||||
|
||||
@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() {
|
||||
|
||||
Reference in New Issue
Block a user