speedup toString search

GitOrigin-RevId: fa27d74a28cce199d521669e17fd893c7eb96cab
This commit is contained in:
Egor Ushakov
2019-07-24 11:30:28 +03:00
committed by intellij-monorepo-bot
parent a06fbfaf0d
commit 26ea8cc0eb
2 changed files with 16 additions and 2 deletions
@@ -1084,4 +1084,18 @@ public abstract class DebuggerUtilsEx extends DebuggerUtils {
}
});
}
@Nullable
public static Method concreteMethodByName(@NotNull ClassType type, String name, String signature) {
//TODO: currently does not include interface default methods
while (type != null) {
for (Method candidate : type.methods()) {
if (candidate.name().equals(name) && candidate.signature().equals(signature) && !candidate.isAbstract()) {
return candidate;
}
}
type = type.superclass();
}
return null;
}
}
@@ -1,4 +1,4 @@
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.debugger.ui.tree.render;
import com.intellij.debugger.DebuggerBundle;
@@ -130,7 +130,7 @@ public class ToStringRenderer extends NodeRendererImpl implements OnDemandRender
@SuppressWarnings({"HardCodedStringLiteral"})
private static boolean overridesToString(Type type) {
if (type instanceof ClassType) {
Method toStringMethod = ((ClassType)type).concreteMethodByName("toString", "()Ljava/lang/String;");
Method toStringMethod = DebuggerUtilsEx.concreteMethodByName((ClassType)type, "toString", "()Ljava/lang/String;");
return toStringMethod != null && !CommonClassNames.JAVA_LANG_OBJECT.equals(toStringMethod.declaringType().name());
}
return false;