Skip to content

Commit 11390e3

Browse files
authored
Fix evaluation and stack frame navigation for ZipEntryStorage (#847)
- Extract type information from ZipEntryStorage source entries - Locate Java project in the workspace for ZipEntryStorage entries Fixes : #86
1 parent d419df0 commit 11390e3

File tree

2 files changed

+80
-2
lines changed

2 files changed

+80
-2
lines changed

org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JDIModelPresentation.java

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2025 IBM Corporation and others.
2+
* Copyright (c) 2000, 2026 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -21,6 +21,7 @@
2121

2222
import org.eclipse.core.resources.IMarker;
2323
import org.eclipse.core.resources.IResource;
24+
import org.eclipse.core.resources.ResourcesPlugin;
2425
import org.eclipse.core.runtime.CoreException;
2526
import org.eclipse.core.runtime.IAdaptable;
2627
import org.eclipse.debug.core.DebugException;
@@ -45,8 +46,13 @@
4546
import org.eclipse.debug.ui.IDebugModelPresentationExtension;
4647
import org.eclipse.debug.ui.IDebugUIConstants;
4748
import org.eclipse.debug.ui.IValueDetailListener;
49+
import org.eclipse.jdt.core.IJavaModel;
50+
import org.eclipse.jdt.core.IJavaProject;
4851
import org.eclipse.jdt.core.IMember;
52+
import org.eclipse.jdt.core.IOrdinaryClassFile;
4953
import org.eclipse.jdt.core.IType;
54+
import org.eclipse.jdt.core.JavaCore;
55+
import org.eclipse.jdt.core.JavaModelException;
5056
import org.eclipse.jdt.core.Signature;
5157
import org.eclipse.jdt.debug.core.IJavaArray;
5258
import org.eclipse.jdt.debug.core.IJavaBreakpoint;
@@ -69,6 +75,7 @@
6975
import org.eclipse.jdt.debug.core.IJavaValue;
7076
import org.eclipse.jdt.debug.core.IJavaVariable;
7177
import org.eclipse.jdt.debug.core.IJavaWatchpoint;
78+
import org.eclipse.jdt.internal.debug.core.JDIDebugPlugin;
7279
import org.eclipse.jdt.internal.debug.core.breakpoints.JavaExceptionBreakpoint;
7380
import org.eclipse.jdt.internal.debug.core.logicalstructures.JDIAllInstancesValue;
7481
import org.eclipse.jdt.internal.debug.core.logicalstructures.JDIReturnValueVariable;
@@ -1187,6 +1194,16 @@ public IEditorInput getEditorInput(Object item) {
11871194
return new LocalFileStorageEditorInput(localFileStorage);
11881195
}
11891196
if (item instanceof ZipEntryStorage zipEntryStorage) {
1197+
String typeName = getTypeName(zipEntryStorage);
1198+
if (typeName != null) {
1199+
IType type = findTypeInWorkspace(typeName);
1200+
if (type != null) {
1201+
IEditorInput input = getClassFileEditorInput(type);
1202+
if (input != null) {
1203+
return input;
1204+
}
1205+
}
1206+
}
11901207
return new ZipEntryStorageEditorInput(zipEntryStorage);
11911208
}
11921209
// for types that correspond to external files, return null so we do not
@@ -1199,6 +1216,44 @@ public IEditorInput getEditorInput(Object item) {
11991216
return EditorUtility.getEditorInput(item);
12001217
}
12011218

1219+
private static String getTypeName(ZipEntryStorage storage) {
1220+
String entryName = storage.getZipEntry().getName();
1221+
if (!entryName.endsWith(".java")) { //$NON-NLS-1$
1222+
return null;
1223+
}
1224+
entryName = entryName.substring(0, entryName.length() - ".java".length()); //$NON-NLS-1$
1225+
return entryName.replace('/', '.');
1226+
}
1227+
1228+
private static IEditorInput getClassFileEditorInput(IType type) {
1229+
try {
1230+
IOrdinaryClassFile classFile = type.getClassFile();
1231+
if (classFile != null && classFile.exists()) {
1232+
return EditorUtility.getEditorInput(classFile);
1233+
}
1234+
} catch (Exception e) {
1235+
}
1236+
return null;
1237+
}
1238+
1239+
private static IType findTypeInWorkspace(String typeName) {
1240+
try {
1241+
IJavaModel model = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot());
1242+
for (IJavaProject jp : model.getJavaProjects()) {
1243+
if (!jp.exists()) {
1244+
continue;
1245+
}
1246+
IType type = jp.findType(typeName);
1247+
if (type != null && type.exists()) {
1248+
return type;
1249+
}
1250+
}
1251+
} catch (JavaModelException e) {
1252+
JDIDebugPlugin.log(e);
1253+
}
1254+
return null;
1255+
}
1256+
12021257
/**
12031258
* @see IDebugModelPresentation#getEditorId(IEditorInput, Object)
12041259
*/

org.eclipse.jdt.debug/model/org/eclipse/jdt/internal/debug/core/JavaDebugUtils.java

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2005, 2017 IBM Corporation and others.
2+
* Copyright (c) 2005, 2026 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -18,6 +18,7 @@
1818
import java.util.List;
1919

2020
import org.eclipse.core.resources.IResource;
21+
import org.eclipse.core.resources.ResourcesPlugin;
2122
import org.eclipse.core.runtime.CoreException;
2223
import org.eclipse.core.runtime.IAdaptable;
2324
import org.eclipse.core.runtime.IPath;
@@ -28,12 +29,15 @@
2829
import org.eclipse.debug.core.model.IDebugTarget;
2930
import org.eclipse.debug.core.model.ISourceLocator;
3031
import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector;
32+
import org.eclipse.debug.core.sourcelookup.containers.ZipEntryStorage;
3133
import org.eclipse.jdt.core.ICompilationUnit;
3234
import org.eclipse.jdt.core.IJavaElement;
35+
import org.eclipse.jdt.core.IJavaModel;
3336
import org.eclipse.jdt.core.IJavaProject;
3437
import org.eclipse.jdt.core.IOrdinaryClassFile;
3538
import org.eclipse.jdt.core.IType;
3639
import org.eclipse.jdt.core.JavaCore;
40+
import org.eclipse.jdt.core.JavaModelException;
3741
import org.eclipse.jdt.core.dom.AST;
3842
import org.eclipse.jdt.core.dom.ASTParser;
3943
import org.eclipse.jdt.core.dom.ASTVisitor;
@@ -430,6 +434,25 @@ public static IJavaProject resolveJavaProject(IJavaStackFrame frame) {
430434
return project;
431435
}
432436
}
437+
if (sourceElement instanceof ZipEntryStorage) {
438+
439+
IJavaType declaringType = frame.getReferenceType();
440+
if (declaringType == null) {
441+
return null;
442+
}
443+
String typeName = declaringType.getName();
444+
IJavaModel model = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot());
445+
446+
for (IJavaProject jp : model.getJavaProjects()) {
447+
try {
448+
if (jp.findType(typeName) != null) {
449+
return jp;
450+
}
451+
} catch (JavaModelException e) {
452+
JDIDebugPlugin.log(e);
453+
}
454+
}
455+
}
433456
}
434457
catch(CoreException ce) {
435458
//do nothing, return null

0 commit comments

Comments
 (0)