when paused use EDT thread as current

This commit is contained in:
Eugene Zhuravlev
2009-09-10 19:06:14 +04:00
parent b4c6348315
commit 024cd48836
2 changed files with 22 additions and 4 deletions
@@ -36,6 +36,7 @@ import com.intellij.psi.PsiCompiledElement;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiFile;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.unscramble.ThreadState;
import com.intellij.xdebugger.AbstractDebuggerSession;
import com.sun.jdi.ObjectCollectedException;
import com.sun.jdi.ThreadReference;
@@ -44,6 +45,7 @@ import com.sun.jdi.request.EventRequest;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -367,12 +369,23 @@ public class DebuggerSession implements AbstractDebuggerSession {
}
if(currentThread == null) {
for (final ThreadReferenceProxyImpl threadReferenceProxy : getProcess().getVirtualMachineProxy().allThreads()) {
currentThread = threadReferenceProxy;
if (currentThread.status() == ThreadReference.THREAD_STATUS_RUNNING) {
final Collection<ThreadReferenceProxyImpl> allThreads = getProcess().getVirtualMachineProxy().allThreads();
// heuristics: try to pre-select EventDispatchThread
for (final ThreadReferenceProxyImpl thread : allThreads) {
if (ThreadState.isEDT(thread.name())) {
currentThread = thread;
break;
}
}
if (currentThread == null) {
// heuristics: display the first thread with RUNNABLE status
for (final ThreadReferenceProxyImpl thread : allThreads) {
currentThread = thread;
if (currentThread.status() == ThreadReference.THREAD_STATUS_RUNNING) {
break;
}
}
}
}
StackFrameProxyImpl proxy = null;
@@ -128,6 +128,11 @@ public class ThreadState {
}
public boolean isEDT() {
return getName().startsWith("AWT-EventQueue");
final String name = getName();
return isEDT(name);
}
public static boolean isEDT(String name) {
return name.startsWith("AWT-EventQueue");
}
}