Investigation: e4xmi refactoring issue requires fix in eclipse.jdt.ui repository
Issue Summary
This PR documents the investigation of issue #1169: "[e4][editor] refactoring produces garbage in fragment.e4xmi"
Investigation Findings
After extensive investigation of the eclipse.platform.ui repository, I've determined that this issue cannot be fixed in this repository. The problem requires changes in the eclipse.jdt.ui repository instead.
Root Cause
When refactoring Java class names in Eclipse, JDT's rename refactoring updates references in e4xmi files. However, it appears to use simple text search-and-replace without understanding the structure of bundleclass URIs or inner class references.
For example, when renaming a class MyPart to NewPart, the following e4xmi entries exist:
<element contributionURI="bundleclass://my.bundle/com.example.MyPart"/>
<handler contributionURI="bundleclass://my.bundle/com.example.MyPart$MyHandler"/>
The text-based replacement can produce "garbage" results because:
- It doesn't understand that
MyPart$MyHandleris an inner class reference - Multiple occurrences of the class name in the same file can lead to incorrect replacements
- The bundleclass URI structure
bundleclass://bundle/fully.qualified.ClassNamerequires special handling
Evidence from Investigation
- No e4-aware rename participant exists in platform.ui: Searched the entire codebase for any code that updates e4xmi files during refactoring - none found
- JDT owns Java refactoring: The rename participant that handles Java type renames is in eclipse.jdt.ui, not eclipse.platform.ui
-
Similar patterns exist: Found
NLSAccessorFieldRenameParticipantin JDT that handles NLS field renames, indicating the pattern to follow
Required Solution
The fix needs to be implemented in eclipse.jdt.ui by creating a rename participant that:
- Parses bundleclass URIs correctly (
bundleclass://bundle.name/fully.qualified.ClassName) - Handles inner class references (e.g.,
ClassName$InnerClass) - Updates only the appropriate parts of the class name
- Validates that replacements maintain valid bundleclass URI syntax
Repository Context
This PR is being closed as the work cannot be completed in eclipse.platform.ui. A new issue should be opened in the eclipse.jdt.ui repository to implement the required rename participant.
References
- Issue #1169
- bundleclass URI format:
bundleclass://symbolic.bundle.name/fully.qualified.ClassName - Related file:
bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/URIHelper.java
Original prompt
This section details on the original issue you should resolve
<issue_title>[e4][editor] refactoring produces garbage in fragment.e4xmi</issue_title> <issue_description>If I have a class (e.g. in a shared class) in
fragment.e4xmiand refactor the classname this results in a wild mixture of old and new name somewhere in the middle.This seem to happen mostly if more than one reference is in the
fragment.e4xmi, e.g. if I haveMyPartand a Handler that is an inner class (e.g.MyPart$MyHandler) in a toolbar. </issue_description><agent_instructions>This is likely somewhere in the refactoring participant of e4</agent_instructions>
Comments on the Issue (you are @copilot in this section)
Fixes eclipse-platform/eclipse.platform.ui#1169
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.
Need to check if refactoring of e4 actually happen in platform repository :-\