IDEA-183745 In-place watches are not updated when I switch to another configuration

This commit is contained in:
Egor Ushakov
2017-12-13 19:49:54 +03:00
parent 21e4de949c
commit 9d713daa6b
8 changed files with 46 additions and 83 deletions
@@ -91,7 +91,7 @@ public class XDebugSessionImpl implements XDebugSession {
private XValueMarkers<?, ?> myValueMarkers;
private final String mySessionName;
private @Nullable XDebugSessionTab mySessionTab;
private final XDebugSessionData mySessionData;
private @NotNull final XDebugSessionData mySessionData;
private XBreakpoint<?> myActiveNonLineBreakpoint;
private final EventDispatcher<XDebugSessionListener> myDispatcher = EventDispatcher.create(XDebugSessionListener.class);
private final Project myProject;
@@ -340,6 +340,7 @@ public class XDebugSessionImpl implements XDebugSession {
myDebugProcess.sessionInitialized();
}
@NotNull
public XDebugSessionData getSessionData() {
return mySessionData;
}
@@ -41,6 +41,7 @@ import com.intellij.xdebugger.impl.breakpoints.XBreakpointBase;
import com.intellij.xdebugger.impl.breakpoints.XBreakpointManagerImpl;
import com.intellij.xdebugger.impl.evaluate.quick.common.ValueLookupManager;
import com.intellij.xdebugger.impl.settings.XDebuggerSettingManagerImpl;
import com.intellij.xdebugger.impl.ui.DebuggerUIUtil;
import com.intellij.xdebugger.impl.ui.ExecutionPointHighlighter;
import com.intellij.xdebugger.impl.ui.XDebugSessionTab;
import org.jetbrains.annotations.NotNull;
@@ -244,7 +245,10 @@ public class XDebuggerManagerImpl extends XDebuggerManager implements Persistent
private void onActiveSessionChanged() {
myBreakpointManager.getLineBreakpointManager().queueAllBreakpointsUpdate();
ApplicationManager.getApplication().invokeLater(() -> ValueLookupManager.getInstance(myProject).hideHint(), myProject.getDisposed());
ApplicationManager.getApplication().invokeLater(() -> {
ValueLookupManager.getInstance(myProject).hideHint();
DebuggerUIUtil.repaintCurrentEditor(myProject); // to update inline debugger data
}, myProject.getDisposed());
}
@Override
@@ -1,17 +1,5 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
*/
package com.intellij.xdebugger.impl.evaluate;
@@ -32,7 +20,6 @@ import com.intellij.xdebugger.XSourcePosition;
import com.intellij.xdebugger.frame.presentation.XValuePresentation;
import com.intellij.xdebugger.impl.XDebugSessionImpl;
import com.intellij.xdebugger.impl.XDebuggerManagerImpl;
import com.intellij.xdebugger.impl.frame.XDebugView;
import com.intellij.xdebugger.impl.frame.XVariablesView;
import com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodeImpl;
import com.intellij.xdebugger.impl.ui.tree.nodes.XValueTextRendererImpl;
@@ -60,7 +47,12 @@ public class XDebuggerEditorLinePainter extends EditorLinePainter {
return null;
}
XVariablesView.InlineVariablesInfo data = project.getUserData(XVariablesView.DEBUG_VARIABLES);
XDebugSession session = XDebuggerManager.getInstance(project).getCurrentSession();
if (session == null) {
return null;
}
XVariablesView.InlineVariablesInfo data = XVariablesView.InlineVariablesInfo.get(session);
final Document doc = FileDocumentManager.getInstance().getDocument(file);
if (data == null || doc == null) {
@@ -74,7 +66,6 @@ public class XDebuggerEditorLinePainter extends EditorLinePainter {
}
List<XValueNodeImpl> values = data.get(file, lineNumber, doc.getModificationStamp());
if (values != null && !values.isEmpty()) {
XDebugSession session = XDebugView.getSession(values.iterator().next().getTree());
final int bpLine = getCurrentBreakPointLineInFile(session, file);
boolean isTopFrame = session instanceof XDebugSessionImpl && ((XDebugSessionImpl)session).isTopFrameSelected();
final TextAttributes attributes = bpLine == lineNumber && isTopFrame &&
@@ -1,17 +1,5 @@
/*
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
*/
package com.intellij.xdebugger.impl.frame;
@@ -51,7 +39,6 @@ import java.util.TreeSet;
* @author nik
*/
public class XVariablesView extends XVariablesViewBase implements DataProvider {
public static final Key<InlineVariablesInfo> DEBUG_VARIABLES = Key.create("debug.variables");
private final JPanel myComponent;
public XVariablesView(@NotNull XDebugSessionImpl session) {
@@ -96,7 +83,7 @@ public class XVariablesView extends XVariablesViewBase implements DataProvider {
}
private static void clearInlineData(XDebuggerTree tree) {
tree.getProject().putUserData(DEBUG_VARIABLES, null);
InlineVariablesInfo.set(getSession(tree), null);
tree.updateEditor();
clearInlays(tree);
}
@@ -137,6 +124,20 @@ public class XVariablesView extends XVariablesViewBase implements DataProvider {
public static class InlineVariablesInfo {
private final Map<Pair<VirtualFile, Integer>, Set<Entry>> myData = new THashMap<>();
private final TObjectLongHashMap<VirtualFile> myTimestamps = new ObjectLongHashMap<>();
private static final Key<InlineVariablesInfo> DEBUG_VARIABLES = Key.create("debug.variables");
public static InlineVariablesInfo get(@Nullable XDebugSession session) {
if (session != null) {
return DEBUG_VARIABLES.get(((XDebugSessionImpl)session).getSessionData());
}
return null;
}
public static void set(@Nullable XDebugSession session, InlineVariablesInfo info) {
if (session != null) {
DEBUG_VARIABLES.set(((XDebugSessionImpl)session).getSessionData(), info);
}
}
@Nullable
public synchronized List<XValueNodeImpl> get(@NotNull VirtualFile file, int line, long currentTimestamp) {
@@ -1,17 +1,5 @@
/*
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
*/
package com.intellij.xdebugger.impl.frame;
@@ -82,8 +70,7 @@ public abstract class XVariablesViewBase extends XDebugView {
XDebuggerTree tree = getTree();
tree.setSourcePosition(position);
createNewRootNode(stackFrame);
final Project project = tree.getProject();
project.putUserData(XVariablesView.DEBUG_VARIABLES, new XVariablesView.InlineVariablesInfo());
XVariablesView.InlineVariablesInfo.set(getSession(tree), new XVariablesView.InlineVariablesInfo());
clearInlays(tree);
Object newEqualityObject = stackFrame.getEqualityObject();
if (newEqualityObject != null) {
@@ -95,7 +82,7 @@ public abstract class XVariablesViewBase extends XDebugView {
}
if (position != null && Registry.is("debugger.valueTooltipAutoShowOnSelection")) {
registerInlineEvaluator(stackFrame, position, project);
registerInlineEvaluator(stackFrame, position, tree.getProject());
}
}
@@ -13,6 +13,7 @@ import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.LogicalPosition;
import com.intellij.openapi.editor.colors.EditorColorsScheme;
import com.intellij.openapi.editor.colors.EditorColorsUtil;
import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.keymap.KeymapUtil;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.popup.*;
@@ -469,4 +470,12 @@ public class DebuggerUIUtil {
}
return data;
}
public static void repaintCurrentEditor(Project project) {
Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor();
if (editor != null) {
editor.getContentComponent().revalidate();
editor.getContentComponent().repaint();
}
}
}
@@ -1,17 +1,5 @@
/*
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
*/
package com.intellij.xdebugger.impl.ui.tree;
@@ -21,8 +9,6 @@ import com.intellij.ide.DataManager;
import com.intellij.ide.dnd.aware.DnDAwareTree;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.text.StringUtil;
@@ -78,11 +64,7 @@ public class XDebuggerTree extends DnDAwareTree implements DataProvider, Disposa
private final SingleAlarm myAlarm = new SingleAlarm(new Runnable() {
@Override
public void run() {
final Editor editor = FileEditorManager.getInstance(myProject).getSelectedTextEditor();
if (editor != null) {
editor.getContentComponent().revalidate();
editor.getContentComponent().repaint();
}
DebuggerUIUtil.repaintCurrentEditor(myProject);
}
}, 100, this);
@@ -1,17 +1,5 @@
/*
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
*/
package com.intellij.xdebugger.impl.ui.tree.nodes;
@@ -133,7 +121,7 @@ public class XValueNodeImpl extends XValueContainerNode<XValue> implements XValu
final Document document = FileDocumentManager.getInstance().getDocument(file);
if (document == null) return;
XVariablesView.InlineVariablesInfo data = myTree.getProject().getUserData(XVariablesView.DEBUG_VARIABLES);
XVariablesView.InlineVariablesInfo data = XVariablesView.InlineVariablesInfo.get(XDebugView.getSession(getTree()));
if (data == null) {
return;
}