Skip to content

Commit ab1a15d

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 change if it is already included for renaming.
1 parent 9d2e85f commit ab1a15d

2 files changed

Lines changed: 21 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: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
******************************************************************************/
1616
package org.eclipse.e4.tools.emf.editor3x.refactorparticipants;
1717

18+
import java.net.URI;
1819
import java.util.HashMap;
1920
import java.util.Map;
2021

@@ -62,6 +63,9 @@ public static CompositeChange createChange(IProgressMonitor pProgressMonitor, fi
6263
@Override
6364
public boolean acceptPatternMatch(TextSearchMatchAccess matchAccess) throws CoreException {
6465
final IFile file = matchAccess.getFile();
66+
if (isFileAlreadyIncluded(file)) {
67+
return false;
68+
}
6569
TextFileChange change = changes.get(file);
6670

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

110130
CompositeChange result;

0 commit comments

Comments
 (0)