3D Java Code Editor Mode
Semitransparent, layered 3D class hierarchy visualization integrated into Eclipse Java code editor
Summary:
Introduce a next-generation visualization feature in Eclipse Java editor: a semitransparent, layered 3D class hierarchy overlay directly inside the code canvas. This allows developers to optionally see inherited and overridden code from superclasses in real time, using depth, color, and perspective, in addition to existing separate outline or hierarchy views. User could choose which direction the 3D effect fans out into.
Description:
When working with large object-oriented systems, developers often struggle to track class hierarchies, overridden methods, and inherited/existing code. Current solutions (like "Open Type Hierarchy" or outline views) require switching context, disrupting the flow of coding and comprehension.
Proposed enhancement:
-
Direct inline visualization: Display superclasses’ and inherited code directly behind and alongside the current code in the same editor pane.
-
3D layered effect: Each class layer is shown as an overlaid "virtual sheet" behind the active class.
-
Text-based layering: Instead of colored planes, use text overlays with changes in color, size, and opacity to represent depth and hierarchy.
-
Perspective spread: Layers are horizontally "fanned out" (spread to the right) to avoid overlap and simulate 3D depth. This spread allows for clear line-by-line inspection of which code belongs to which ancestor, and you can immediately also see the ancestors' code perhaps allowing to avoid duplicating or complicating logic.
-
Interactive focus: Developers can adjust focus using special key + mouse + scrollwheel or gesture controls. For example:
- Bringing a superclass forward for detailed inspection.
- Panning perspective in a desired direction.
- Temporarily collapsing or hiding deeper ancestors.
- Highlighting overridden methods automatically.
Benefits:
- Enhanced understanding of inheritance: Developers can instantly see which methods are inherited or overridden without leaving the editing context.
- Reduced cognitive load: No need to mentally map outline or hierarchy information; it’s visible in place.
- Improved code readability and maintainability: Developers gain a full architectural picture at a glance, leading to faster debugging and fewer integration mistakes.
Technical Considerations:
- Requires a rendering system that can support transparent layered text rendering (e.g., leveraging SWT/JFace extensions, OpenGL overlays, or newer GPU-based composition).
- Must ensure editor responsiveness is maintained (e.g., incremental rendering or on-demand layer loading).
- Color, opacity, and text scaling parameters should be configurable for different themes and accessibility needs.
- Ability to toggle or temporarily hide visualization for minimal distraction.
Potential Enhancements (Future Iterations):
- Enable panning and orbiting around layers (full 3D navigation).
- Allow clicking on any superclass method to jump directly to its declaration or history.
- Support visualization for interfaces and multi-inheritance patterns (e.g., multiple implemented interfaces).
Conclusion:
This feature represents a major leap forward in integrated code comprehension tools. By merging the class hierarchy directly into the code editor canvas in a visually layered, intuitive, and interactive way, Eclipse can greatly improve productivity and code quality for Java developers.
✅ Attached is some pseudocode/sample code via the ThreeDEditorEnhancer to further explain the RFE. ✅ AI suggests: NO NEED to patch any core Eclipse code to achieve this as a "3D mode" — all necessary hooks exist via plugin extension points and editor APIs (unverified).
- Install your ThreeDHierarchyPainter on the SourceViewer
- Add a toggle action to the editor’s toolbar/menu, EditorActionBarContributor
PseudoJavaCodeEditorPerspectiveHierarchyOverlayWithCamera.txt ThreeDEditorEnhancer-sample.txt ThreeDHierarchyPainter.-sample.txt
Thanks for this proposal. This idea seems fun but isn't IMO necessarily something we want to maintain as part of a mainstream IDE at the moment. I would recommend if you want to implement this for Eclipse IDE, that you do it in a dedicated plugin and share it on Eclipse Marketplace. And maybe later, inclusion in default IDE can be considered.
AI generated implementation plan:
Are there any Eclipse Java code editor extensions/plugins that, like this approach, operate entirely via overlays, painters, or other minimal-intrusion hooks, and do NOT create their own editor instance?
✅ Short Answer: Yes, There Are — and it’s the recommended way! Eclipse’s plugin ecosystem is built around this approach.
Most visual code annotations/extensions work by plugging into the existing Java code editor, not by replacing it.
Examples of Plugins/Extensions That Use This Minimal-Invasive Overlay Technique
1. SpotBugs Eclipse Plugin
-
What it does: Underlines and annotates detected bug patterns directly in the existing Java code editor.
-
How it works:
- Uses the annotation model and painter/overlay APIs.
- Renders overlays (squiggle lines, markers, hover popups) on top of
StyledText. - Does not require a new editor instance.
2. Checkstyle Eclipse Plugin
-
What it does: Marks style violations inline in the existing code editor.
-
How it works:
- Uses annotation model, overlays, and sometimes custom
IPainterimplementations. - All overlays drawn on top of the current code; editor instance is untouched.
- Uses annotation model, overlays, and sometimes custom
3. SonarLint Eclipse Plugin
-
What it does: In-editor code quality feedback (issues highlighted in real time).
-
How it works:
- Relies on annotations, text markers, and possibly custom painting via the same APIs described.
- Integrated with existing editor, not a replacement.
4. Error/Warning/Task Markers (Built-in Eclipse)
-
What it does: Built-in problem annotations (red/yellow squiggles, task tags, etc.).
-
How it works:
- Handled by
IPainterand annotation overlays on theStyledTextof the active editor.
- Handled by
5. EclEmma Java Code Coverage
-
What it does: Highlights lines in the Java code editor that are covered/not covered by tests.
-
How it works:
- Draws colored backgrounds/overlays via painters.
- Seamlessly integrates into the standard Java editor instance.
6. Code Minimap/Overview (Various plugins)
-
What it does: Shows a tiny code map/scrollbar or in-line code outline.
-
How it works:
- Adds auxiliary view or overlays; does not spawn a new editor.
🟢 Key Takeaways from these plugins
- All of the above do NOT create their own code editor instance.
- They work by adding annotation models, painters, overlays, or other renderers to the existing Java code editor.
- They leverage extension points in Eclipse (often via
plugin.xmland programmatic install in the editor lifecycle).
🔎 How do they achieve this in code?
They typically do the following:
- Listen to editor lifecycle events (e.g., through
IStartup, listeners, or throughEditorActionBarContributor). - Get a handle on the
SourceViewerorStyledTextwidget from the existing editor instance. - Install a painter or annotation provider (
IPainter, custom annotations, etc.) on the viewer. - Draw overlays, highlights, underlines, or in-line UI elements — never replacing the core editor.
🛠️ Steps to Implement a 3D Overlay Plugin for Eclipse Java Editor
1. Create an Eclipse Plug-in Project
- In Eclipse:
File → New → Project... → Plug-in Project - Target at least Eclipse 2021-09 (or later) for best API stability.
- Choose “Rich Client Application” (no) and “Would you like to create a rich client application?” (no).
2. Add JDT UI & Text Dependencies
In your MANIFEST.MF:
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.jface.text,
org.eclipse.ui.editors,
org.eclipse.jdt.ui,
org.eclipse.jdt.core
3. Implement the 3D Overlay Painter (IPainter)
Create a class (e.g., ThreeDHierarchyPainter) that implements org.eclipse.jface.text.IPainter.
- This class will do the drawing of the “virtual 3D code layers” in the Java editor.
- The logic for camera, perspective, and hierarchical code comes here.
4. Contribute an Editor Action (Toggle/Enable 3D Mode)
- Implement an Eclipse
ActionorHandler(with menu/toolbar contribution). - This action will activate/deactivate your painter (show/hide overlays).
5. Listen for Editor Open Events and Install Your Painter
You need to detect when a Java editor opens, and then install your painter.
You can do this via a IPartListener2 (to hook into IWorkbenchPartReference events), for example:
public class ThreeDHierarchyPlugin implements IPartListener2 {
@Override
public void partOpened(IWorkbenchPartReference partRef) {
if (partRef.getPart(false) instanceof CompilationUnitEditor) {
CompilationUnitEditor editor = (CompilationUnitEditor) partRef.getPart(false);
ISourceViewer viewer = editor.getViewer();
if (viewer instanceof ITextViewerExtension2) {
ThreeDHierarchyPainter painter = new ThreeDHierarchyPainter(viewer);
((ITextViewerExtension2) viewer).addPainter(painter);
// Store the painter reference, link to action, etc.
}
}
}
// Implement other required methods with empty bodies.
}
Register this listener in your plugin startup/activator.
6. Add UI Contributions
-
Use
plugin.xmlor code to add menu or toolbar items:-
Example:
- Menu:
Window > Show View > 3D Java Hierarchy - Toolbar: add an icon to toggle 3D mode
- Menu:
-
7. Fetch Superclass/Hierarchy Code with JDT APIs
- Use
org.eclipse.jdt.core.ITypeHierarchyand AST APIs to fetch superclass/interface code. - Use JDT presentation mechanisms to style code for overlay.
- Cache/fetch as needed to avoid performance hits.
8. Overlay the Code (Projecting in 3D)
- In your painter’s
paint(int reason)method, use the GC (graphics context) to draw code layers with scaling, translation, and alpha transparency (as in the Java sample code earlier). - Use the StyledText widget for dimensions and font metrics.
9. Clean up on Editor Close
- Remove your painter when the editor is closed to prevent memory leaks.
10. Test, Polish, and Package
- Test on multiple platforms and with various Java projects.
- Package with
exportwizard ormvn clean verifyif Tycho/Mavenized. - Optionally, publish to the Eclipse Marketplace.
🚦 Summary Table
| Step | What You Do | Why |
|---|---|---|
| 1. Plug-in Project | Create via Eclipse wizard | Scaffolding |
| 2. Dependencies | Add JDT UI/Text to MANIFEST.MF | For Java editor APIs |
| 3. IPainter | Implement custom painter class | Draw overlays |
| 4. Editor Action | Create toggle action/menu/toolbar | User enables/disables 3D mode |
| 5. Listener | Install painter on Java editor open | Plugin-only, no code patching |
| 6. UI Contribution | Add menu/toolbar item | User control |
| 7. JDT Hierarchy | Fetch code with JDT APIs | Show super/interface code |
| 8. Overlay Drawing | Use GC to draw in 3D projection | Visual effect |
| 9. Cleanup | Uninstall painter on close | No leaks |
| 10. Packaging | Export/plugin.xml | Distribute |
🚀 Proven Plugin Pattern
- Minimally invasive: Only adds overlays, doesn’t touch editor core code.
- Plug and play: Works with any Eclipse Java editor; just enable/disable with your action.
- Easy to uninstall: Remove plugin to return to normal.