diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java index b39ca5d6274d..7fedaa0b473f 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java @@ -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 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; } diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerManagerImpl.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerManagerImpl.java index f4ce31303a50..f738f3c08cff 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerManagerImpl.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerManagerImpl.java @@ -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 diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/XDebuggerEditorLinePainter.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/XDebuggerEditorLinePainter.java index be10479c4b4b..8c16cdb1afb1 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/XDebuggerEditorLinePainter.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/XDebuggerEditorLinePainter.java @@ -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 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 && diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XVariablesView.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XVariablesView.java index 7f7b8b1a8049..19a456674295 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XVariablesView.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XVariablesView.java @@ -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 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, Set> myData = new THashMap<>(); private final TObjectLongHashMap myTimestamps = new ObjectLongHashMap<>(); + private static final Key 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 get(@NotNull VirtualFile file, int line, long currentTimestamp) { diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XVariablesViewBase.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XVariablesViewBase.java index f05531e1d542..c2c8bf16879b 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XVariablesViewBase.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XVariablesViewBase.java @@ -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()); } } diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/DebuggerUIUtil.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/DebuggerUIUtil.java index c8ee40043c54..5739d91d9d3a 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/DebuggerUIUtil.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/DebuggerUIUtil.java @@ -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(); + } + } } diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/XDebuggerTree.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/XDebuggerTree.java index fc2e0bd63c7e..b312751002df 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/XDebuggerTree.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/XDebuggerTree.java @@ -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); diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueNodeImpl.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueNodeImpl.java index e705d320392a..5149006a1ce5 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueNodeImpl.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueNodeImpl.java @@ -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 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; }