Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDani Megert2011-03-18 14:22:50 +0000
committerDani Megert2011-03-18 14:22:50 +0000
commit8fd1a8c7928f3ca9e2f0080671775bc97cfc0eb5 (patch)
tree8580b950a567227f336103a9986b155b84e1ea7a /org.eclipse.search/search
parent7cf215ea8862f1564f1dbeae7dacbe04353eeac1 (diff)
downloadeclipse.platform.text-8fd1a8c7928f3ca9e2f0080671775bc97cfc0eb5.tar.gz
eclipse.platform.text-8fd1a8c7928f3ca9e2f0080671775bc97cfc0eb5.tar.xz
eclipse.platform.text-8fd1a8c7928f3ca9e2f0080671775bc97cfc0eb5.zip
Fixed bug 320533: Replacing text in a set of files should only modify each physical resource oncev20110322-0800
Diffstat (limited to 'org.eclipse.search/search')
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/text/ReplaceRefactoring.java28
1 files changed, 24 insertions, 4 deletions
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/ReplaceRefactoring.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/ReplaceRefactoring.java
index e6598b153d4..da46eef81f8 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/ReplaceRefactoring.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/ReplaceRefactoring.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.search.internal.ui.text;
+import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -23,6 +24,8 @@ import java.util.regex.PatternSyntaxException;
import com.ibm.icu.text.Collator;
+import org.eclipse.core.filesystem.URIUtil;
+
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -209,7 +212,9 @@ public class ReplaceRefactoring extends Refactoring {
FileMatch[] matches= lineElement.getMatches(fResult);
for (int i= 0; i < matches.length; i++) {
FileMatch fileMatch= matches[i];
- getBucket(fileMatch.getFile()).add(fileMatch);
+ if (!isAlreadyCollected(fileMatch)) {
+ getBucket(fileMatch.getFile()).add(fileMatch);
+ }
}
} else if (object instanceof IContainer) {
IContainer container= (IContainer) object;
@@ -223,10 +228,12 @@ public class ReplaceRefactoring extends Refactoring {
Collection bucket= null;
for (int i= 0; i < matches.length; i++) {
FileMatch fileMatch= (FileMatch) matches[i];
- if (bucket == null) {
- bucket= getBucket((IFile)object);
- }
+ if (!isAlreadyCollected(fileMatch)) {
+ if (bucket == null) {
+ bucket= getBucket((IFile)object);
+ }
bucket.add(fileMatch);
+ }
}
}
}
@@ -249,6 +256,19 @@ public class ReplaceRefactoring extends Refactoring {
return !fMatches.isEmpty();
}
+ private boolean isAlreadyCollected(FileMatch match) {
+ URI uri= match.getFile().getLocationURI();
+ if (uri == null)
+ return false;
+
+ for (Iterator iter= fAffectedLocations.iterator(); iter.hasNext();) {
+ if (URIUtil.equals((URI)iter.next(), uri))
+ return true;
+ }
+ fAffectedLocations.add(uri);
+ return false;
+ }
+
private Collection getBucket(IFile file) {
Collection col= (Collection) fMatches.get(file);
if (col == null) {

Back to the top