WI-78463 PHP debugger looses watches each time

(cherry picked from commit 796d63927f8727722be94abe445dad8ae13aae8f)

IJ-CR-148573

GitOrigin-RevId: f8ee02a2b82032df0e9f5c6a4b9ed012aeecc2f2
This commit is contained in:
Egor Ushakov
2024-11-05 12:26:20 +01:00
committed by intellij-monorepo-bot
parent 17653852c0
commit 36cd6c127a
6 changed files with 44 additions and 26 deletions

View File

@@ -843,16 +843,6 @@ f:com.intellij.xdebugger.impl.inline.InlineWatch
- f:setMarker():Z
- f:setPosition(com.intellij.xdebugger.XSourcePosition):V
- f:updatePosition():Z
c:com.intellij.xdebugger.impl.inline.InlineWatchNodeImpl
- com.intellij.xdebugger.impl.ui.tree.nodes.WatchNode
- com.intellij.xdebugger.impl.ui.tree.nodes.WatchNodeImpl
- <init>(com.intellij.xdebugger.impl.ui.tree.XDebuggerTree,com.intellij.xdebugger.impl.ui.tree.nodes.XDebuggerTreeNode,com.intellij.xdebugger.impl.inline.InlineWatch,com.intellij.xdebugger.frame.XStackFrame):V
- getEvaluationOrigin():com.intellij.xdebugger.impl.ui.tree.nodes.XEvaluationOrigin
- getLink():com.intellij.xdebugger.frame.XDebuggerTreeNodeHyperlink
- getPosition():com.intellij.xdebugger.XSourcePosition
- getValueContainer():com.intellij.xdebugger.frame.XValue
- getWatch():com.intellij.xdebugger.impl.inline.InlineWatch
- nodeRemoved():V
c:com.intellij.xdebugger.impl.inline.InlineWatchesRootNode
- com.intellij.xdebugger.impl.ui.tree.nodes.WatchesRootNode
- <init>(com.intellij.xdebugger.impl.ui.tree.XDebuggerTree,com.intellij.xdebugger.impl.frame.XWatchesView,java.util.List,java.util.List,com.intellij.xdebugger.frame.XStackFrame,Z):V
@@ -1574,6 +1564,7 @@ c:com.intellij.xdebugger.impl.ui.tree.nodes.WatchNodeImpl
- getEvaluationOrigin():com.intellij.xdebugger.impl.ui.tree.nodes.XEvaluationOrigin
- getExpression():com.intellij.xdebugger.XExpression
- getValueContainer():com.intellij.xdebugger.frame.XValue
- p:shouldUpdateInlineDebuggerData():Z
c:com.intellij.xdebugger.impl.ui.tree.nodes.WatchesRootNode
- com.intellij.xdebugger.impl.ui.tree.nodes.XValueContainerNode
- <init>(com.intellij.xdebugger.impl.ui.tree.XDebuggerTree,com.intellij.xdebugger.impl.frame.XWatchesView,java.util.List,com.intellij.xdebugger.frame.XStackFrame,Z):V
@@ -1711,6 +1702,7 @@ c:com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodeImpl
- setPresentation(javax.swing.Icon,com.intellij.xdebugger.frame.presentation.XValuePresentation,Z):V
- setPresentation(javax.swing.Icon,java.lang.String,java.lang.String,Z):V
- setValueModificationStarted():V
- p:shouldUpdateInlineDebuggerData():Z
f:com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodePresentationConfigurator
- <init>():V
- s:setPresentation(javax.swing.Icon,com.intellij.xdebugger.frame.presentation.XValuePresentation,Z,com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodePresentationConfigurator$ConfigurableXValueNode):V

View File

@@ -60,6 +60,10 @@ public class XVariablesView extends XVariablesViewBase {
getTree().markNodesObsolete();
}
if (event == SessionEvent.STOPPED) {
mySession.clear();
}
if (event == SessionEvent.BEFORE_RESUME) {
return;
}
@@ -84,14 +88,19 @@ public class XVariablesView extends XVariablesViewBase {
super.dispose();
}
private static void clearInlineData(XDebuggerTree tree) {
InlineVariablesInfo.set(getSession(tree), null);
@Nullable
protected final XDebugSessionImpl getSession() {
return mySession.get();
}
private void clearInlineData(XDebuggerTree tree) {
InlineVariablesInfo.set(getSession(), null);
tree.updateEditor();
clearInlays(tree);
}
protected void addEmptyMessage(XValueContainerNode<?> root) {
XDebugSession session = getSession(getPanel());
XDebugSession session = getSession();
if (session != null) {
if (!session.isStopped() && session.isPaused()) {
root.setInfoMessage(XDebuggerBundle.message("message.frame.is.not.available"), null);
@@ -115,7 +124,7 @@ public class XVariablesView extends XVariablesViewBase {
}
protected void uiDataSnapshot(@NotNull DataSink sink) {
XDebugSessionImpl session = mySession.get();
XDebugSessionImpl session = getSession();
XSourcePosition position = session == null ? null : session.getCurrentPosition();
if (position != null) {
sink.lazy(CommonDataKeys.VIRTUAL_FILE, () -> position.getFile());

View File

@@ -294,7 +294,7 @@ public class XWatchesViewImpl extends XVariablesView implements DnDNativeTarget,
XExpression expression = myEvaluateComboBox.getExpression();
if (!XDebuggerUtilImpl.isEmptyExpression(expression)) {
myEvaluateComboBox.saveTextInHistory();
XDebugSession session = getSession(getTree());
XDebugSession session = getSession();
if (session != null) {
ApplicationManager.getApplication().getMessageBus().syncPublisher(XEvaluationListener.TOPIC)
.inlineEvaluatorInvoked(session, expression);
@@ -417,7 +417,7 @@ public class XWatchesViewImpl extends XVariablesView implements DnDNativeTarget,
public void addWatchExpression(@NotNull XExpression expression, int index, final boolean navigateToWatchNode, boolean noDuplicates) {
ThreadingAssertions.assertEventDispatchThread();
XDebugSession session = getSession(getTree());
XDebugSessionImpl session = getSession();
boolean found = false;
if (noDuplicates) {
for (WatchNode child : myRootNode.getWatchChildren()) {
@@ -432,7 +432,7 @@ public class XWatchesViewImpl extends XVariablesView implements DnDNativeTarget,
updateSessionData();
}
if (navigateToWatchNode && session != null) {
XDebugSessionTab.showWatchesView((XDebugSessionImpl)session);
XDebugSessionTab.showWatchesView(session);
}
}
@@ -463,12 +463,12 @@ public class XWatchesViewImpl extends XVariablesView implements DnDNativeTarget,
@Override
public void addInlineWatchExpression(@NotNull InlineWatch watch, int index, boolean navigateToWatchNode) {
ThreadingAssertions.assertEventDispatchThread();
XDebugSession session = getSession(getTree());
XDebugSessionImpl session = getSession();
((InlineWatchesRootNode)myRootNode).addInlineWatchExpression(session != null ? session.getCurrentStackFrame() : null, watch, index, navigateToWatchNode);
if (navigateToWatchNode && session != null) {
XDebugSessionTab.showWatchesView((XDebugSessionImpl)session);
XDebugSessionTab.showWatchesView(session);
}
}
@@ -520,10 +520,10 @@ public class XWatchesViewImpl extends XVariablesView implements DnDNativeTarget,
@NotNull
protected List<XExpression> getExpressions() {
XDebuggerTree tree = getTree();
XDebugSession session = getSession(tree);
XDebugSessionImpl session = getSession();
List<XExpression> expressions;
if (session != null) {
expressions = ((XDebugSessionImpl)session).getSessionData().getWatchExpressions();
expressions = session.getSessionData().getWatchExpressions();
}
else {
XDebuggerTreeNode root = tree.getRoot();
@@ -595,8 +595,8 @@ public class XWatchesViewImpl extends XVariablesView implements DnDNativeTarget,
public void updateSessionData() {
List<XExpression> watchExpressions = myRootNode.getWatchExpressions();
XDebugSession session = getSession(getTree());
XDebugSessionData data = (session != null) ? ((XDebugSessionImpl)session).getSessionData()
XDebugSessionImpl session = getSession();
XDebugSessionData data = (session != null) ? session.getSessionData()
: getData(XDebugSessionData.DATA_KEY, getTree());
if (data != null) {
data.setWatchExpressions(watchExpressions);

View File

@@ -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-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.xdebugger.impl.inline;
import com.intellij.icons.AllIcons;
@@ -19,6 +19,8 @@ import com.intellij.xdebugger.impl.ui.XDebuggerUIConstants;
import com.intellij.xdebugger.impl.ui.XValueTextProvider;
import com.intellij.xdebugger.impl.ui.tree.XDebuggerTree;
import com.intellij.xdebugger.impl.ui.tree.nodes.*;
import com.intellij.xdebugger.settings.XDebuggerSettingsManager;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -26,6 +28,7 @@ import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.List;
@ApiStatus.Internal
public class InlineWatchNodeImpl extends WatchNodeImpl implements InlineWatchNode {
private final InlineWatch myWatch;
private final List<Inlay<InlineDebugRenderer>> myInlays = new ArrayList<>();
@@ -87,6 +90,11 @@ public class InlineWatchNodeImpl extends WatchNodeImpl implements InlineWatchNod
return XEvaluationOrigin.INLINE_WATCH;
}
@Override
protected boolean shouldUpdateInlineDebuggerData() {
return XDebuggerSettingsManager.getInstance().getDataViewSettings().isShowValuesInline();
}
private static class XInlineWatchValue extends XNamedValue implements XValueTextProvider {
private final XExpression myExpression;
private final XDebuggerTree myTree;

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2024 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.tree.nodes;
import com.intellij.icons.AllIcons;
@@ -83,6 +83,11 @@ public class WatchNodeImpl extends XValueNodeImpl implements WatchNode {
}
}
@Override
protected boolean shouldUpdateInlineDebuggerData() { // regular watches do not have inline data
return false;
}
private static class XWatchValue extends XNamedValue {
private final XExpression myExpression;
private final XDebuggerTree myTree;

View File

@@ -92,7 +92,7 @@ public class XValueNodeImpl extends XValueContainerNode<XValue> implements XValu
boolean alreadyHasInline = myValuePresentation != null;
myValuePresentation = valuePresentation;
myRawValue = XValuePresentationUtil.computeValueText(valuePresentation);
if (XDebuggerSettingsManager.getInstance().getDataViewSettings().isShowValuesInline() && !alreadyHasInline) {
if (shouldUpdateInlineDebuggerData() && !alreadyHasInline) {
updateInlineDebuggerData();
}
updateText();
@@ -101,6 +101,10 @@ public class XValueNodeImpl extends XValueContainerNode<XValue> implements XValu
myTree.nodeLoaded(this, myName);
}
protected boolean shouldUpdateInlineDebuggerData() {
return XDebuggerSettingsManager.getInstance().getDataViewSettings().isShowValuesInline();
}
private void updateInlineDebuggerData() {
try {
XDebugSession session = XDebugView.getSession(getTree());