mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fixed lambdas args to slots mapping
This commit is contained in:
+2
-10
@@ -648,17 +648,9 @@ public class EvaluatorBuilderImpl implements EvaluatorBuilder {
|
||||
final String localName = psiVar.getName();
|
||||
PsiClass variableClass = getContainingClass(psiVar);
|
||||
if (getContextPsiClass() == null || getContextPsiClass().equals(variableClass)) {
|
||||
PsiElement method = PsiTreeUtil.getContextOfType(expression, PsiMethod.class, PsiLambdaExpression.class);
|
||||
PsiElement method = DebuggerUtilsEx.getContainingMethod(expression);
|
||||
boolean canScanFrames = method instanceof PsiLambdaExpression || ContextUtil.isJspImplicit(element);
|
||||
LocalVariableEvaluator localVarEvaluator = new LocalVariableEvaluator(localName, canScanFrames);
|
||||
if (psiVar instanceof PsiParameter) {
|
||||
final PsiParameter param = (PsiParameter)psiVar;
|
||||
final PsiParameterList paramList = PsiTreeUtil.getParentOfType(param, PsiParameterList.class, true);
|
||||
if (paramList != null) {
|
||||
localVarEvaluator.setParameterIndex(paramList.getParameterIndex(param));
|
||||
}
|
||||
}
|
||||
myResult = localVarEvaluator;
|
||||
myResult = new LocalVariableEvaluator(localName, canScanFrames);
|
||||
return;
|
||||
}
|
||||
// the expression references final var outside the context's class (in some of the outer classes)
|
||||
|
||||
-17
@@ -42,7 +42,6 @@ import com.intellij.psi.PsiVariable;
|
||||
import com.sun.jdi.*;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
class LocalVariableEvaluator implements Evaluator {
|
||||
@@ -52,17 +51,12 @@ class LocalVariableEvaluator implements Evaluator {
|
||||
private EvaluationContextImpl myContext;
|
||||
private LocalVariableProxyImpl myEvaluatedVariable;
|
||||
private final boolean myCanScanFrames;
|
||||
private int myParameterIndex = -1;
|
||||
|
||||
public LocalVariableEvaluator(String localVariableName, boolean canScanFrames) {
|
||||
myLocalVariableName = localVariableName;
|
||||
myCanScanFrames = canScanFrames;
|
||||
}
|
||||
|
||||
public void setParameterIndex(int parameterIndex) {
|
||||
myParameterIndex = parameterIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object evaluate(EvaluationContextImpl context) throws EvaluateException {
|
||||
StackFrameProxyImpl frameProxy = context.getFrameProxy();
|
||||
@@ -108,17 +102,6 @@ class LocalVariableEvaluator implements Evaluator {
|
||||
catch (Exception e1) {
|
||||
LOG.info(e1);
|
||||
}
|
||||
|
||||
if (topFrame) {
|
||||
if (myParameterIndex < 0) {
|
||||
throw e;
|
||||
}
|
||||
final List<Value> values = frameProxy.getArgumentValues();
|
||||
if (values.isEmpty() || myParameterIndex >= values.size()) {
|
||||
throw e;
|
||||
}
|
||||
return values.get(myParameterIndex);
|
||||
}
|
||||
}
|
||||
|
||||
if (myCanScanFrames) {
|
||||
|
||||
@@ -868,7 +868,7 @@ public abstract class DebuggerUtilsEx extends DebuggerUtils {
|
||||
|
||||
@Nullable
|
||||
public static PsiElement getContainingMethod(@Nullable PsiElement elem) {
|
||||
return PsiTreeUtil.getParentOfType(elem, PsiMethod.class, PsiLambdaExpression.class);
|
||||
return PsiTreeUtil.getContextOfType(elem, PsiMethod.class, PsiLambdaExpression.class);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -119,15 +119,17 @@ public class LocalVariablesUtil {
|
||||
ourInitializationOk = success;
|
||||
}
|
||||
|
||||
public static Map<DecompiledLocalVariable, Value> fetchValues(StackFrameProxyImpl frameProxy, DebugProcess process) throws Exception {
|
||||
public static Map<DecompiledLocalVariable, Value> fetchValues(@NotNull StackFrameProxyImpl frameProxy, DebugProcess process) throws Exception {
|
||||
Map<DecompiledLocalVariable, Value> map = new LinkedHashMap<DecompiledLocalVariable, Value>(); // LinkedHashMap for correct order
|
||||
|
||||
List<Value> argValues = frameProxy.getArgumentValues();
|
||||
|
||||
// gather code variables names
|
||||
MultiMap<Integer, String> namesMap = calcNames(new SimpleStackFrameContext(frameProxy, process));
|
||||
MultiMap<Integer, String> namesMap = calcNames(new SimpleStackFrameContext(frameProxy, process), argValues.size());
|
||||
|
||||
// first add arguments
|
||||
int slot = 0;
|
||||
for (Value value : frameProxy.getArgumentValues()) {
|
||||
for (Value value : argValues) {
|
||||
map.put(new DecompiledLocalVariable(slot, true, null, namesMap.get(slot)), value);
|
||||
slot++;
|
||||
}
|
||||
@@ -258,7 +260,7 @@ public class LocalVariablesUtil {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static MultiMap<Integer, String> calcNames(@NotNull final StackFrameContext context) {
|
||||
private static MultiMap<Integer, String> calcNames(@NotNull final StackFrameContext context, final int methodArgsNumber) {
|
||||
return ApplicationManager.getApplication().runReadAction(new Computable<MultiMap<Integer, String>>() {
|
||||
@Override
|
||||
public MultiMap<Integer, String> compute() {
|
||||
@@ -269,8 +271,10 @@ public class LocalVariablesUtil {
|
||||
PsiParameterList params = DebuggerUtilsEx.getParameterList(method);
|
||||
if (params != null) {
|
||||
MultiMap<Integer, String> res = new MultiMap<Integer, String>();
|
||||
for (int i = 0; i < params.getParametersCount(); i++) {
|
||||
res.putValue(i, params.getParameters()[i].getName());
|
||||
int paramCount = params.getParametersCount();
|
||||
int offset = Math.max(0, methodArgsNumber - paramCount);
|
||||
for (int i = 0; i < paramCount; i++) {
|
||||
res.putValue(i + offset, params.getParameters()[i].getName());
|
||||
}
|
||||
PsiElement body = DebuggerUtilsEx.getBody(method);
|
||||
if (body != null) {
|
||||
|
||||
Reference in New Issue
Block a user