mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
avoid unnecessary and time-consuming type resolution for method parameters
This commit is contained in:
+13
-8
@@ -30,7 +30,10 @@ import com.intellij.debugger.engine.evaluation.EvaluateRuntimeException;
|
||||
import com.intellij.debugger.engine.evaluation.EvaluationContextImpl;
|
||||
import com.intellij.debugger.impl.DebuggerUtilsEx;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.sun.jdi.*;
|
||||
import com.sun.jdi.ClassType;
|
||||
import com.sun.jdi.Method;
|
||||
import com.sun.jdi.ObjectReference;
|
||||
import com.sun.jdi.ReferenceType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -127,14 +130,16 @@ public class MethodEvaluator implements Evaluator {
|
||||
_refType = ((ClassType)referenceType).superclass();
|
||||
}
|
||||
Method jdiMethod = DebuggerUtils.findMethod(_refType, myMethodName, signature);
|
||||
if (jdiMethod == null || jdiMethod.argumentTypes().size() != args.size()) {
|
||||
if (signature == null) {
|
||||
// we know nothing about expected method's signature, so trying to match my method name and parameter count
|
||||
// dummy matching, may be improved with types matching later
|
||||
List<Method> methods = _refType.methodsByName(myMethodName);
|
||||
for (Method method : methods) {
|
||||
List<Type> types = method.argumentTypes();
|
||||
if (types.size() == args.size()) {
|
||||
jdiMethod = method;
|
||||
break;
|
||||
// IMPORTANT! using argumentTypeNames() instead of argumentTypes() to avoid type resolution inside JDI, which may be time-consuming
|
||||
if (jdiMethod == null || jdiMethod.argumentTypeNames().size() != args.size()) {
|
||||
for (Method method : _refType.methodsByName(myMethodName)) {
|
||||
if (method.argumentTypeNames().size() == args.size()) {
|
||||
jdiMethod = method;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user