Skip to content

Commit 91be283

Browse files
committed
Fixes corruption of e4xmi files when class is renamed
The corruption happens in a setup with a top level Maven project and plug-in projects in sub directories (eg bundles). If the name of a Java handler class is renamed in the Java file the e4xmi file is found twice with full workspace path plug-in project path This leads to 2 changes in one e4xmi file with the same text, offset and length. If the old and new names are of different length the corruption occurs. This fix skips the file if it is already included for renaming.
1 parent 9d2e85f commit 91be283

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

e4tools/bundles/org.eclipse.e4.tools.emf.editor3x/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
22
Bundle-ManifestVersion: 2
33
Bundle-Name: %Bundle-Name
44
Bundle-SymbolicName: org.eclipse.e4.tools.emf.editor3x;singleton:=true
5-
Bundle-Version: 4.10.200.qualifier
5+
Bundle-Version: 4.10.300.qualifier
66
Bundle-RequiredExecutionEnvironment: JavaSE-21
77
Require-Bundle: org.eclipse.ui;bundle-version="3.6.0",
88
org.eclipse.core.runtime;bundle-version="3.29.0",

e4tools/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/refactorparticipants/RefactorParticipantDelegate.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ public static CompositeChange createChange(IProgressMonitor pProgressMonitor, fi
6262
@Override
6363
public boolean acceptPatternMatch(TextSearchMatchAccess matchAccess) throws CoreException {
6464
final IFile file = matchAccess.getFile();
65+
if (isFileAlreadyIncluded(file)) {
66+
return false;
67+
}
6568
TextFileChange change = changes.get(file);
6669

6770
if (change == null) {
@@ -105,6 +108,22 @@ public boolean acceptPatternMatch(TextSearchMatchAccess matchAccess) throws Core
105108
edit));
106109
return true;
107110
}
111+
112+
/**
113+
* Tests whether the given file is already included in the
114+
* {@code changes} map.
115+
*
116+
* @param file
117+
* a file to be tested
118+
* @return true if the file has a location URI and is already
119+
* included in the {@code changes} map otherwise false
120+
*/
121+
private boolean isFileAlreadyIncluded(IFile file) {
122+
final URI uri = file.getLocationURI();
123+
return uri != null
124+
&& changes.entrySet().stream().anyMatch(
125+
e -> uri.equals(e.getKey().getLocationURI()));
126+
}
108127
};
109128

110129
CompositeChange result;

0 commit comments

Comments
 (0)