Skip to content

Commit a42d7f7

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 any of the paths (workspace or project) are already included for renaming.
1 parent 9a3e908 commit a42d7f7

2 files changed

Lines changed: 23 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: 22 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,25 @@ public boolean acceptPatternMatch(TextSearchMatchAccess matchAccess) throws Core
105108
edit));
106109
return true;
107110
}
111+
112+
/**
113+
* Exclude files with their sub project paths that are already
114+
* included with their full workspace path or the other way around.
115+
*
116+
* @param file
117+
* a file to be tested
118+
* @return true if the file is already included in the
119+
* {@code changes} list
120+
*/
121+
private boolean isFileAlreadyIncluded(IFile file) {
122+
boolean match = changes.entrySet().stream() //
123+
.anyMatch(e -> e.getKey().getFullPath().toOSString().endsWith(file.getFullPath().toOSString()) //
124+
|| file.getFullPath().toOSString().endsWith(e.getKey().getFullPath().toOSString()));
125+
if (match) {
126+
return true;
127+
}
128+
return false;
129+
}
108130
};
109131

110132
CompositeChange result;

0 commit comments

Comments
 (0)