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
2121
2222import org .eclipse .core .resources .IMarker ;
2323import org .eclipse .core .resources .IResource ;
24+ import org .eclipse .core .resources .ResourcesPlugin ;
2425import org .eclipse .core .runtime .CoreException ;
2526import org .eclipse .core .runtime .IAdaptable ;
2627import org .eclipse .debug .core .DebugException ;
4546import org .eclipse .debug .ui .IDebugModelPresentationExtension ;
4647import org .eclipse .debug .ui .IDebugUIConstants ;
4748import org .eclipse .debug .ui .IValueDetailListener ;
49+ import org .eclipse .jdt .core .IJavaModel ;
50+ import org .eclipse .jdt .core .IJavaProject ;
4851import org .eclipse .jdt .core .IMember ;
52+ import org .eclipse .jdt .core .IOrdinaryClassFile ;
4953import org .eclipse .jdt .core .IType ;
54+ import org .eclipse .jdt .core .JavaCore ;
55+ import org .eclipse .jdt .core .JavaModelException ;
5056import org .eclipse .jdt .core .Signature ;
5157import org .eclipse .jdt .debug .core .IJavaArray ;
5258import org .eclipse .jdt .debug .core .IJavaBreakpoint ;
6975import org .eclipse .jdt .debug .core .IJavaValue ;
7076import org .eclipse .jdt .debug .core .IJavaVariable ;
7177import org .eclipse .jdt .debug .core .IJavaWatchpoint ;
78+ import org .eclipse .jdt .internal .debug .core .JDIDebugPlugin ;
7279import org .eclipse .jdt .internal .debug .core .breakpoints .JavaExceptionBreakpoint ;
7380import org .eclipse .jdt .internal .debug .core .logicalstructures .JDIAllInstancesValue ;
7481import 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 */
0 commit comments