mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
thread assertion fix
This commit is contained in:
+39
-12
@@ -18,12 +18,14 @@ package com.intellij.debugger.ui.impl.watch;
|
||||
import com.intellij.debugger.DebuggerBundle;
|
||||
import com.intellij.debugger.DebuggerContext;
|
||||
import com.intellij.debugger.SourcePosition;
|
||||
import com.intellij.debugger.engine.DebugProcessImpl;
|
||||
import com.intellij.debugger.engine.DebuggerManagerThreadImpl;
|
||||
import com.intellij.debugger.engine.DebuggerUtils;
|
||||
import com.intellij.debugger.engine.JVMNameUtil;
|
||||
import com.intellij.debugger.engine.evaluation.EvaluateException;
|
||||
import com.intellij.debugger.engine.evaluation.EvaluateExceptionUtil;
|
||||
import com.intellij.debugger.engine.evaluation.EvaluationContextImpl;
|
||||
import com.intellij.debugger.engine.events.DebuggerContextCommandImpl;
|
||||
import com.intellij.debugger.impl.DebuggerContextImpl;
|
||||
import com.intellij.debugger.impl.DebuggerSession;
|
||||
import com.intellij.debugger.impl.PositionUtil;
|
||||
@@ -32,6 +34,8 @@ import com.intellij.debugger.ui.tree.FieldDescriptor;
|
||||
import com.intellij.debugger.ui.tree.NodeDescriptor;
|
||||
import com.intellij.debugger.ui.tree.render.ClassRenderer;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
@@ -98,20 +102,43 @@ public class FieldDescriptorImpl extends ValueDescriptorImpl implements FieldDes
|
||||
PsiClass aClass = facade.findClass(type.name().replace('$', '.'), scope);
|
||||
if (aClass == null) {
|
||||
// trying to search, assuming declaring class is an anonymous class
|
||||
try {
|
||||
final List<Location> locations = type.allLineLocations();
|
||||
if (!locations.isEmpty()) {
|
||||
// important: use the last location to be sure the position will be within the anonymous class
|
||||
final Location lastLocation = locations.get(locations.size() - 1);
|
||||
final SourcePosition position = context.getDebugProcess().getPositionManager().getSourcePosition(lastLocation);
|
||||
if (position != null) {
|
||||
aClass = JVMNameUtil.getClassAt(position);
|
||||
final DebugProcessImpl debugProcess = context.getDebugProcess();
|
||||
if (debugProcess != null) {
|
||||
final Computable<PsiClass> classComputable = new Computable<PsiClass>() {
|
||||
public PsiClass compute() {
|
||||
try {
|
||||
final List<Location> locations = type.allLineLocations();
|
||||
if (!locations.isEmpty()) {
|
||||
// important: use the last location to be sure the position will be within the anonymous class
|
||||
final Location lastLocation = locations.get(locations.size() - 1);
|
||||
final SourcePosition position = debugProcess.getPositionManager().getSourcePosition(lastLocation);
|
||||
if (position != null) {
|
||||
return JVMNameUtil.getClassAt(position);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (AbsentInformationException ignored) {
|
||||
}
|
||||
catch (ClassNotPreparedException ignored) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
if (!DebuggerManagerThreadImpl.isManagerThread()) {
|
||||
final Ref<PsiClass> classRef = new Ref<PsiClass>(null);
|
||||
debugProcess.getManagerThread().invokeAndWait(new DebuggerContextCommandImpl(context) {
|
||||
public Priority getPriority() {
|
||||
return Priority.HIGH;
|
||||
}
|
||||
public void threadAction() {
|
||||
classRef.set(classComputable.compute());
|
||||
}
|
||||
});
|
||||
aClass = classRef.get();
|
||||
}
|
||||
else {
|
||||
aClass = classComputable.compute();
|
||||
}
|
||||
}
|
||||
catch (AbsentInformationException ignored) {
|
||||
}
|
||||
catch (ClassNotPreparedException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user