summaryrefslogtreecommitdiff
path: root/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java
diff options
context:
space:
mode:
Diffstat (limited to 'platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java')
-rw-r--r--platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java87
1 files changed, 46 insertions, 41 deletions
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 762855510a1e..8ee2f1ee587a 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java
@@ -25,7 +25,6 @@ import com.intellij.execution.process.ProcessAdapter;
import com.intellij.execution.process.ProcessEvent;
import com.intellij.execution.process.ProcessHandler;
import com.intellij.execution.runners.ExecutionEnvironment;
-import com.intellij.execution.runners.ProgramRunner;
import com.intellij.execution.ui.ConsoleView;
import com.intellij.execution.ui.ConsoleViewContentType;
import com.intellij.execution.ui.RunContentDescriptor;
@@ -108,10 +107,9 @@ public class XDebugSessionImpl implements XDebugSession {
private final EventDispatcher<XDebugSessionListener> myDispatcher = EventDispatcher.create(XDebugSessionListener.class);
private final Project myProject;
private final @Nullable ExecutionEnvironment myEnvironment;
- private final @Nullable ProgramRunner myRunner;
private boolean myStopped;
private boolean myPauseActionSupported;
- private boolean myShowTabOnSuspend;
+ private final AtomicBoolean myShowTabOnSuspend;
private final List<AnAction> myRestartActions = new SmartList<AnAction>();
private final List<AnAction> myExtraStopActions = new SmartList<AnAction>();
private final List<AnAction> myExtraActions = new SmartList<AnAction>();
@@ -121,23 +119,19 @@ public class XDebugSessionImpl implements XDebugSession {
private volatile boolean breakpointsInitialized;
private boolean autoInitBreakpoints = true;
- public XDebugSessionImpl(@NotNull ExecutionEnvironment environment,
- @Nullable ProgramRunner runner,
- @NotNull XDebuggerManagerImpl debuggerManager) {
- this(environment, runner, debuggerManager, environment.getRunProfile().getName(), environment.getRunProfile().getIcon(), false);
+ public XDebugSessionImpl(@NotNull ExecutionEnvironment environment, @NotNull XDebuggerManagerImpl debuggerManager) {
+ this(environment, debuggerManager, environment.getRunProfile().getName(), environment.getRunProfile().getIcon(), false);
}
public XDebugSessionImpl(@Nullable ExecutionEnvironment environment,
- @Nullable ProgramRunner runner,
@NotNull XDebuggerManagerImpl debuggerManager,
@NotNull String sessionName,
@Nullable Icon icon,
boolean showTabOnSuspend) {
myEnvironment = environment;
- myRunner = runner;
mySessionName = sessionName;
myDebuggerManager = debuggerManager;
- myShowTabOnSuspend = showTabOnSuspend;
+ myShowTabOnSuspend = new AtomicBoolean(showTabOnSuspend);
myProject = debuggerManager.getProject();
ValueLookupManager.getInstance(myProject).startListening();
myIcon = icon;
@@ -158,7 +152,7 @@ public class XDebugSessionImpl implements XDebugSession {
}
private void assertSessionTabInitialized() {
- if (myShowTabOnSuspend) {
+ if (myShowTabOnSuspend.get()) {
LOG.error("Debug tool window isn't shown yet because debug process isn't suspended");
}
else {
@@ -176,6 +170,7 @@ public class XDebugSessionImpl implements XDebugSession {
myPauseActionSupported = isSupported;
}
+ @NotNull
public List<AnAction> getRestartActions() {
return myRestartActions;
}
@@ -186,6 +181,7 @@ public class XDebugSessionImpl implements XDebugSession {
}
}
+ @NotNull
public List<AnAction> getExtraActions() {
return myExtraActions;
}
@@ -208,7 +204,7 @@ public class XDebugSessionImpl implements XDebugSession {
@Override
public void rebuildViews() {
- if (!myShowTabOnSuspend && mySessionTab != null) {
+ if (!myShowTabOnSuspend.get() && mySessionTab != null) {
mySessionTab.rebuildViews();
}
}
@@ -262,7 +258,7 @@ public class XDebugSessionImpl implements XDebugSession {
return myCurrentPosition;
}
- public XDebugSessionTab init(final XDebugProcess process, @NotNull final XDebugSessionData sessionData) {
+ public XDebugSessionTab init(@NotNull XDebugProcess process, @NotNull XDebugSessionData sessionData, @Nullable RunContentDescriptor contentToReuse) {
LOG.assertTrue(myDebugProcess == null);
myDebugProcess = process;
mySessionData = sessionData;
@@ -279,8 +275,8 @@ public class XDebugSessionImpl implements XDebugSession {
});
//todo[nik] make 'createConsole()' method return ConsoleView
myConsoleView = (ConsoleView)myDebugProcess.createConsole();
- if (!myShowTabOnSuspend) {
- initSessionTab();
+ if (!myShowTabOnSuspend.get()) {
+ initSessionTab(contentToReuse);
}
return mySessionTab;
@@ -316,11 +312,12 @@ public class XDebugSessionImpl implements XDebugSession {
@Override
public RunnerLayoutUi getUI() {
assertSessionTabInitialized();
+ assert mySessionTab != null;
return mySessionTab.getUi();
}
- private void initSessionTab() {
- mySessionTab = new XDebugSessionTab(myProject, this, myIcon, myEnvironment, myRunner);
+ private void initSessionTab(@Nullable RunContentDescriptor contentToReuse) {
+ mySessionTab = XDebugSessionTab.create(this, myIcon, myEnvironment, contentToReuse);
myDebugProcess.sessionInitialized();
}
@@ -536,12 +533,12 @@ public class XDebugSessionImpl implements XDebugSession {
private void doResume() {
if (!myPaused.getAndSet(false)) return;
- final XSourcePosition oldPosition = myCurrentPosition;
myDispatcher.getMulticaster().beforeSessionResume();
myDebuggerManager.setActiveSession(this, null, false, null);
mySuspendContext = null;
myCurrentExecutionStack = null;
myCurrentStackFrame = null;
+ adjustMouseTrackingCounter(myCurrentPosition, -1);
myCurrentPosition = null;
myActiveNonLineBreakpoint = null;
UIUtil.invokeLaterIfNeeded(new Runnable() {
@@ -550,9 +547,6 @@ public class XDebugSessionImpl implements XDebugSession {
if (mySessionTab != null) {
mySessionTab.getUi().clearAttractionBy(XDebuggerUIConstants.LAYOUT_VIEW_BREAKPOINT_CONDITION);
}
- if (oldPosition != null) {
- adjustMouseTrackingCounter(oldPosition, -1);
- }
}
});
myDispatcher.getMulticaster().sessionResumed();
@@ -794,32 +788,37 @@ public class XDebugSessionImpl implements XDebugSession {
if (myCurrentPosition != null) {
myDebuggerManager.setActiveSession(this, myCurrentPosition, false, getPositionIconRenderer(true));
}
- UIUtil.invokeLaterIfNeeded(new Runnable() {
- @Override
- public void run() {
- if (myShowTabOnSuspend) {
- myShowTabOnSuspend = false;
- initSessionTab();
+ adjustMouseTrackingCounter(myCurrentPosition, 1);
+
+ if (myShowTabOnSuspend.compareAndSet(true, false)) {
+ UIUtil.invokeLaterIfNeeded(new Runnable() {
+ @Override
+ public void run() {
+ initSessionTab(null);
showSessionTab();
}
- if (myCurrentPosition != null) {
- adjustMouseTrackingCounter(myCurrentPosition, 1);
- }
- }
- });
+ });
+ }
+
myDispatcher.getMulticaster().sessionPaused();
}
- private void adjustMouseTrackingCounter(@NotNull XSourcePosition position, int increment) {
- if (ApplicationManager.getApplication().isUnitTestMode()) return;
+ private void adjustMouseTrackingCounter(final XSourcePosition position, final int increment) {
+ if (position == null || ApplicationManager.getApplication().isUnitTestMode()) return;
- Editor editor = XDebuggerUtilImpl.createEditor(new OpenFileDescriptor(myProject, position.getFile()));
- if (editor != null) {
- JComponent component = editor.getComponent();
- Object o = component.getClientProperty(EditorImpl.IGNORE_MOUSE_TRACKING);
- Integer value = ((o instanceof Integer) ? (Integer)o : 0) + increment;
- component.putClientProperty(EditorImpl.IGNORE_MOUSE_TRACKING, value > 0 ? value : null);
- }
+ // need to always invoke later to maintain order of increment/decrement
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ Editor editor = XDebuggerUtilImpl.createEditor(new OpenFileDescriptor(myProject, position.getFile()));
+ if (editor != null) {
+ JComponent component = editor.getComponent();
+ Object o = component.getClientProperty(EditorImpl.IGNORE_MOUSE_TRACKING);
+ Integer value = ((o instanceof Integer) ? (Integer)o : 0) + increment;
+ component.putClientProperty(EditorImpl.IGNORE_MOUSE_TRACKING, value > 0 ? value : null);
+ }
+ }
+ });
}
@Override
@@ -851,6 +850,12 @@ public class XDebugSessionImpl implements XDebugSession {
if (!myProject.isDisposed()) {
myProject.getMessageBus().syncPublisher(XDebuggerManager.TOPIC).processStopped(myDebugProcess);
}
+
+ if (mySessionTab != null) {
+ mySessionTab.detachFromSession();
+ }
+
+ adjustMouseTrackingCounter(myCurrentPosition, -1);
myCurrentPosition = null;
myCurrentExecutionStack = null;
myCurrentStackFrame = null;