mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup
This commit is contained in:
@@ -19,8 +19,6 @@ import com.intellij.debugger.jdi.ThreadReferenceProxyImpl;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Set;
|
||||
|
||||
public class SuspendManagerUtil {
|
||||
@@ -36,9 +34,8 @@ public class SuspendManagerUtil {
|
||||
}
|
||||
|
||||
public static SuspendContextImpl findContextByThread(SuspendManager suspendManager, ThreadReferenceProxyImpl thread) {
|
||||
for (ListIterator<SuspendContextImpl> iterator = ((SuspendManagerImpl) suspendManager).getPausedContexts().listIterator(); iterator.hasNext();) {
|
||||
SuspendContextImpl context = iterator.next();
|
||||
if(context.getThread() == thread) {
|
||||
for (SuspendContextImpl context : ((SuspendManagerImpl)suspendManager).getPausedContexts()) {
|
||||
if (context.getThread() == thread) {
|
||||
return context;
|
||||
}
|
||||
}
|
||||
@@ -78,8 +75,7 @@ public class SuspendManagerUtil {
|
||||
LOG.assertTrue(context.myResumedThreads == null);
|
||||
|
||||
if(data.myResumedThreads != null) {
|
||||
for (Iterator<ThreadReferenceProxyImpl> iterator = data.myResumedThreads.iterator(); iterator.hasNext();) {
|
||||
ThreadReferenceProxyImpl resumedThreads = iterator.next();
|
||||
for (ThreadReferenceProxyImpl resumedThreads : data.myResumedThreads) {
|
||||
resumedThreads.resume();
|
||||
}
|
||||
context.myResumedThreads = data.myResumedThreads;
|
||||
@@ -101,8 +97,7 @@ public class SuspendManagerUtil {
|
||||
LOG.debug("Resuming SuspendContextImpl...");
|
||||
}
|
||||
if(context.myResumedThreads != null) {
|
||||
for (Iterator<ThreadReferenceProxyImpl> iterator = context.myResumedThreads.iterator(); iterator.hasNext();) {
|
||||
ThreadReferenceProxyImpl resumedThreads = iterator.next();
|
||||
for (ThreadReferenceProxyImpl resumedThreads : context.myResumedThreads) {
|
||||
resumedThreads.suspend();
|
||||
}
|
||||
context.myResumedThreads = null;
|
||||
|
||||
+2
-5
@@ -25,11 +25,6 @@ import com.sun.jdi.Value;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* User: lex
|
||||
* Date: Aug 28, 2003
|
||||
* Time: 2:02:29 PM
|
||||
*/
|
||||
public final class EvaluationContextImpl implements EvaluationContext{
|
||||
private final Value myThisObject;
|
||||
private final SuspendContextImpl mySuspendContext;
|
||||
@@ -48,6 +43,7 @@ public final class EvaluationContextImpl implements EvaluationContext{
|
||||
return myThisObject;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public SuspendContextImpl getSuspendContext() {
|
||||
return mySuspendContext;
|
||||
@@ -77,6 +73,7 @@ public final class EvaluationContextImpl implements EvaluationContext{
|
||||
return copy;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ClassLoaderReference getClassLoader() throws EvaluateException {
|
||||
DebuggerManagerThreadImpl.assertIsManagerThread();
|
||||
|
||||
+2
@@ -28,6 +28,7 @@ public class BlockStatementEvaluator implements Evaluator {
|
||||
myStatements = statements;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object evaluate(EvaluationContextImpl context) throws EvaluateException {
|
||||
Object result = context.getSuspendContext().getDebugProcess().getVirtualMachineProxy().mirrorOf();
|
||||
for (Evaluator statement : myStatements) {
|
||||
@@ -36,6 +37,7 @@ public class BlockStatementEvaluator implements Evaluator {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Modifier getModifier() {
|
||||
return myStatements.length > 0 ? myStatements[myStatements.length - 1].getModifier() : null;
|
||||
}
|
||||
|
||||
+4
-2
@@ -20,10 +20,10 @@
|
||||
*/
|
||||
package com.intellij.debugger.engine.evaluation.expression;
|
||||
|
||||
import com.intellij.debugger.engine.evaluation.EvaluationContextImpl;
|
||||
import com.intellij.debugger.DebuggerBundle;
|
||||
import com.intellij.debugger.engine.evaluation.EvaluateException;
|
||||
import com.intellij.debugger.engine.evaluation.EvaluateExceptionUtil;
|
||||
import com.intellij.debugger.DebuggerBundle;
|
||||
import com.intellij.debugger.engine.evaluation.EvaluationContextImpl;
|
||||
import com.sun.jdi.BooleanValue;
|
||||
import com.sun.jdi.Value;
|
||||
|
||||
@@ -38,10 +38,12 @@ class ConditionalExpressionEvaluator implements Evaluator {
|
||||
myElseEvaluator = elseEvaluator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Modifier getModifier() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object evaluate(EvaluationContextImpl context) throws EvaluateException {
|
||||
Value condition = (Value)myConditionEvaluator.evaluate(context);
|
||||
if (condition == null || !(condition instanceof BooleanValue)) {
|
||||
|
||||
+10
-5
@@ -15,11 +15,11 @@
|
||||
*/
|
||||
package com.intellij.debugger.engine.evaluation.expression;
|
||||
|
||||
import com.intellij.debugger.DebuggerBundle;
|
||||
import com.intellij.debugger.engine.evaluation.EvaluateException;
|
||||
import com.intellij.debugger.engine.evaluation.EvaluateExceptionUtil;
|
||||
import com.intellij.debugger.engine.evaluation.EvaluationContext;
|
||||
import com.intellij.debugger.engine.evaluation.EvaluationContextImpl;
|
||||
import com.intellij.debugger.DebuggerBundle;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.sun.jdi.Value;
|
||||
|
||||
@@ -40,16 +40,19 @@ public class ExpressionEvaluatorImpl implements ExpressionEvaluator {
|
||||
}
|
||||
|
||||
//call evaluate before
|
||||
@Override
|
||||
public Value getValue() {
|
||||
return myValue;
|
||||
}
|
||||
|
||||
//call evaluate before
|
||||
@Override
|
||||
public Modifier getModifier() {
|
||||
return myEvaluator.getModifier();
|
||||
}
|
||||
|
||||
// EvaluationContextImpl should be at the same stackFrame as it was in the call to EvaluatorBuilderImpl.build
|
||||
@Override
|
||||
public Value evaluate(final EvaluationContext context) throws EvaluateException {
|
||||
if (!context.getDebugProcess().isAttached()) {
|
||||
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("error.vm.disconnected"));
|
||||
@@ -61,22 +64,24 @@ public class ExpressionEvaluatorImpl implements ExpressionEvaluator {
|
||||
|
||||
Object value = myEvaluator.evaluate((EvaluationContextImpl)context);
|
||||
|
||||
if(value != null && !(value instanceof Value)) {
|
||||
if (value != null && !(value instanceof Value)) {
|
||||
throw EvaluateExceptionUtil
|
||||
.createEvaluateException(DebuggerBundle.message("evaluation.error.invalid.expression", ""));
|
||||
}
|
||||
|
||||
myValue = (Value) value;
|
||||
myValue = (Value)value;
|
||||
return myValue;
|
||||
}
|
||||
catch (Throwable/*IncompatibleThreadStateException*/ e) {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug(e);
|
||||
}
|
||||
if(e instanceof EvaluateException)
|
||||
if (e instanceof EvaluateException) {
|
||||
throw ((EvaluateException)e);
|
||||
else
|
||||
}
|
||||
else {
|
||||
throw EvaluateExceptionUtil.createEvaluateException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+11
-2
@@ -53,6 +53,7 @@ class LocalVariableEvaluator implements Evaluator {
|
||||
myParameterIndex = parameterIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object evaluate(EvaluationContextImpl context) throws EvaluateException {
|
||||
StackFrameProxyImpl frameProxy = context.getFrameProxy();
|
||||
if (frameProxy == null) {
|
||||
@@ -109,37 +110,45 @@ class LocalVariableEvaluator implements Evaluator {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Modifier getModifier() {
|
||||
Modifier modifier = null;
|
||||
if (myEvaluatedVariable != null && myContext != null) {
|
||||
modifier = new Modifier() {
|
||||
@Override
|
||||
public boolean canInspect() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSetValue() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(Value value) throws ClassNotLoadedException, InvalidTypeException {
|
||||
StackFrameProxyImpl frameProxy = myContext.getFrameProxy();
|
||||
try {
|
||||
assert frameProxy != null;
|
||||
frameProxy.setValue(myEvaluatedVariable, value);
|
||||
}
|
||||
catch (EvaluateException e) {
|
||||
LOG.error(e);
|
||||
LOG.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type getExpectedType() throws ClassNotLoadedException {
|
||||
try {
|
||||
return myEvaluatedVariable.getType();
|
||||
} catch (EvaluateException e) {
|
||||
}
|
||||
catch (EvaluateException e) {
|
||||
LOG.error(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NodeDescriptorImpl getInspectItem(Project project) {
|
||||
return new LocalVariableDescriptorImpl(project, myEvaluatedVariable);
|
||||
}
|
||||
|
||||
+4
-1
@@ -22,6 +22,7 @@ package com.intellij.debugger.engine.evaluation.expression;
|
||||
|
||||
import com.intellij.debugger.DebuggerBundle;
|
||||
import com.intellij.debugger.engine.DebugProcessImpl;
|
||||
import com.intellij.debugger.engine.DebuggerUtils;
|
||||
import com.intellij.debugger.engine.JVMName;
|
||||
import com.intellij.debugger.engine.evaluation.EvaluateException;
|
||||
import com.intellij.debugger.engine.evaluation.EvaluateExceptionUtil;
|
||||
@@ -53,10 +54,12 @@ public class MethodEvaluator implements Evaluator {
|
||||
myArgumentEvaluators = argumentEvaluators;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Modifier getModifier() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object evaluate(EvaluationContextImpl context) throws EvaluateException {
|
||||
if(!context.getDebugProcess().isAttached()) return null;
|
||||
DebugProcessImpl debugProcess = context.getDebugProcess();
|
||||
@@ -126,7 +129,7 @@ public class MethodEvaluator implements Evaluator {
|
||||
if (requiresSuperObject && (referenceType instanceof ClassType)) {
|
||||
_refType = ((ClassType)referenceType).superclass();
|
||||
}
|
||||
final Method jdiMethod = DebuggerUtilsEx.findMethod(_refType, myMethodName, signature);
|
||||
final Method jdiMethod = DebuggerUtils.findMethod(_refType, myMethodName, signature);
|
||||
if (jdiMethod == null) {
|
||||
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.no.instance.method", methodName));
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ public abstract class InvokeThread<E extends PrioritizedTask> {
|
||||
myOwner = owner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
synchronized (this) {
|
||||
while (myRequestFuture == null) {
|
||||
@@ -174,7 +175,7 @@ public abstract class InvokeThread<E extends PrioritizedTask> {
|
||||
}
|
||||
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("Request " + this.toString() + " exited");
|
||||
LOG.debug("Request " + toString() + " exited");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,11 +26,15 @@ import com.intellij.debugger.engine.evaluation.EvaluateExceptionUtil;
|
||||
import com.intellij.debugger.engine.jdi.StackFrameProxy;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.sun.jdi.*;
|
||||
import gnu.trove.THashMap;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class StackFrameProxyImpl extends JdiProxy implements StackFrameProxy {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.debugger.jdi.StackFrameProxyImpl");
|
||||
@@ -43,7 +47,7 @@ public class StackFrameProxyImpl extends JdiProxy implements StackFrameProxy {
|
||||
private ObjectReference myThisReference;
|
||||
private ClassLoaderReference myClassLoader;
|
||||
private Boolean myIsObsolete = null;
|
||||
private Map<LocalVariable,Value> myAllValues;
|
||||
private Map<LocalVariable, Value> myAllValues;
|
||||
|
||||
public StackFrameProxyImpl(ThreadReferenceProxyImpl threadProxy, @NotNull StackFrame frame, int fromBottomIndex /* 1-based */) {
|
||||
super(threadProxy.getVirtualMachine());
|
||||
@@ -252,6 +256,12 @@ public class StackFrameProxyImpl extends JdiProxy implements StackFrameProxy {
|
||||
return variable != null ? new LocalVariableProxyImpl(this, variable) : null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Value visibleValueByName(@NotNull String name) throws EvaluateException {
|
||||
LocalVariable variable = visibleVariableByNameInt(name);
|
||||
return variable != null ? getValue(new LocalVariableProxyImpl(this, variable)) : null;
|
||||
}
|
||||
|
||||
protected LocalVariable visibleVariableByNameInt(String name) throws EvaluateException {
|
||||
DebuggerManagerThreadImpl.assertIsManagerThread();
|
||||
InvalidStackFrameException error = null;
|
||||
@@ -283,8 +293,7 @@ public class StackFrameProxyImpl extends JdiProxy implements StackFrameProxy {
|
||||
InvalidStackFrameException error = null;
|
||||
for (int attempt = 0; attempt < 2; attempt++) {
|
||||
try {
|
||||
final Map<LocalVariable, Value> allValues = getAllValues();
|
||||
return allValues.get(localVariable.getVariable());
|
||||
return getAllValues().get(localVariable.getVariable());
|
||||
}
|
||||
catch (InvalidStackFrameException e) {
|
||||
error = e;
|
||||
@@ -332,13 +341,8 @@ public class StackFrameProxyImpl extends JdiProxy implements StackFrameProxy {
|
||||
checkValid();
|
||||
if (myAllValues == null) {
|
||||
try {
|
||||
final StackFrame stackFrame = getStackFrame();
|
||||
final Map<LocalVariable, Value> values = stackFrame.getValues(stackFrame.visibleVariables());
|
||||
myAllValues = new HashMap<LocalVariable, Value>(values.size());
|
||||
for (final LocalVariable variable : values.keySet()) {
|
||||
final Value value = values.get(variable);
|
||||
myAllValues.put(variable, value);
|
||||
}
|
||||
StackFrame stackFrame = getStackFrame();
|
||||
myAllValues = new THashMap<LocalVariable, Value>(stackFrame.getValues(stackFrame.visibleVariables()));
|
||||
}
|
||||
catch (InconsistentDebugInfoException ignored) {
|
||||
clearCaches();
|
||||
|
||||
+2
@@ -31,10 +31,12 @@ public interface EvaluationContext extends StackFrameContext{
|
||||
|
||||
EvaluationContext createEvaluationContext(Value value);
|
||||
|
||||
@NotNull
|
||||
SuspendContext getSuspendContext();
|
||||
|
||||
Project getProject();
|
||||
|
||||
@Nullable
|
||||
ClassLoaderReference getClassLoader() throws EvaluateException;
|
||||
|
||||
@Nullable
|
||||
|
||||
Reference in New Issue
Block a user