Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supplying JDK version to disambiguate types to open #609

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2024 IBM Corporation and others.
* Copyright (c) 2000, 2025 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -42,6 +42,8 @@
import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin;
import org.eclipse.jdt.internal.debug.ui.actions.OpenFromClipboardAction;
import org.eclipse.jdt.internal.debug.ui.actions.OpenTypeAction;
import org.eclipse.jdt.launching.IVMInstall;
import org.eclipse.jdt.launching.JavaRuntime;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.text.BadLocationException;
Expand Down Expand Up @@ -295,6 +297,7 @@ public IStatus processAmbiguousResults(List<Object> matches, String typeName, in
return openClipboard(matches, line, typeName);
}
}

/**
* Handles exceptions details
*
Expand Down Expand Up @@ -352,6 +355,7 @@ private boolean filterClasses(Object obj, String methodSignature, String methodN
* @return Returns a standard OK status with an "ok" message.
*/
private IStatus openClipboard(List<Object> results, int lineNumber, String type) {
results = filterBinaryTypes(results, generatedLink.get());
OpenFromClipboardAction.handleMatches(results, lineNumber, type, ConsoleMessages.JavaDebugStackTraceHyperlink_dialog_title);
return Status.OK_STATUS;
}
Expand Down Expand Up @@ -746,4 +750,46 @@ private static String removeModuleInfo(String typeName) {
}
return typeName;
}

/**
* Intermediate method to filter Binary Types based on given version
*
* @return List of Objects with filtered Binary types
* @param extracted
* Filtered or Processed Binary/Source Types
* @param link
* Stack trace from the console
*/
private List<Object> filterBinaryTypes(List<Object> extracted, String link) {
if (link != null) {
List<Object> filteredResults = new ArrayList<>();
int binaryInserted = 0;
try {
Pattern pattern = Pattern.compile("@(.*?)\\/"); //$NON-NLS-1$
Matcher match = pattern.matcher(link);
if (match.find()) {
String jdkVersion = match.group(1);
for (Object ob : extracted) {
if (ob instanceof IType type && type.isBinary()) {
IVMInstall installedJava = JavaRuntime.getVMInstall(type.getJavaProject());
String jdkAvailable = installedJava.getInstallLocation().getAbsolutePath();
if (jdkAvailable.contains(jdkVersion)) {
filteredResults.add(ob);
binaryInserted++;
}
} else {
filteredResults.add(ob);
}
}
}
} catch (CoreException e) {
return extracted;
}
if (binaryInserted == 0) {
return extracted;
}
return filteredResults;
}
return extracted;
}
}
Loading