From 13316bafd7db94b95ec907f3de9db45689013c06 Mon Sep 17 00:00:00 2001 From: sougandhs Date: Wed, 18 Sep 2024 12:11:42 +0530 Subject: [PATCH] JavaStackStrace ambiguity Itype fix --- .../ui/console/JavaStackTraceHyperlink.java | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/console/JavaStackTraceHyperlink.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/console/JavaStackTraceHyperlink.java index 82a1a03657..de1284426a 100644 --- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/console/JavaStackTraceHyperlink.java +++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/console/JavaStackTraceHyperlink.java @@ -34,7 +34,6 @@ import org.eclipse.jdt.core.search.SearchEngine; import org.eclipse.jdt.core.search.TypeNameMatch; import org.eclipse.jdt.core.search.TypeNameMatchRequestor; -import org.eclipse.jdt.internal.core.SourceType; import org.eclipse.jdt.internal.debug.core.JavaDebugUtils; import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin; import org.eclipse.jdt.internal.debug.ui.actions.OpenFromClipboardAction; @@ -211,21 +210,20 @@ public IStatus runInUIThread(IProgressMonitor monitor) { if (firstMethodStartIndex != -1 && firstMethodClosing != -1) { String firstMethod = originalHyperLink2.substring(firstMethodStartIndex + 1, firstMethodClosing + 1); for (Object obj : matches) { - @SuppressWarnings("restriction") - SourceType source = (SourceType) obj; - try { - @SuppressWarnings("restriction") - IMethod[] methods = source.getMethods(); - for (IMethod method : methods) { - int indexOfClosing = method.toString().indexOf(')'); - int indexOfStart = method.toString().substring(0, indexOfClosing + 1).lastIndexOf(' '); - String methodName = method.toString().substring(indexOfStart + 1, indexOfClosing + 1); - if (methodName.equals(firstMethod)) { - exactMatchesFiltered.add(obj); + if (obj instanceof IType type) { + try { + IMethod[] methods = type.getMethods(); + for (IMethod method : methods) { + int indexOfClosing = method.toString().indexOf(')'); + int indexOfStart = method.toString().substring(0, indexOfClosing + 1).lastIndexOf(' '); + String methodName = method.toString().substring(indexOfStart + 1, indexOfClosing + 1); + if (methodName.equals(firstMethod)) { + exactMatchesFiltered.add(obj); + } } + } catch (JavaModelException e) { + JDIDebugUIPlugin.log(e); } - } catch (JavaModelException e) { - JDIDebugUIPlugin.log(e); } } }