Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1036)

Unified Diff: editor/tools/plugins/com.google.dart.engine.services/src/com/google/dart/engine/services/internal/refactoring/RenameRefactoringImpl.java

Issue 23498016: Update only unique references during rename refactoring. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: editor/tools/plugins/com.google.dart.engine.services/src/com/google/dart/engine/services/internal/refactoring/RenameRefactoringImpl.java
diff --git a/editor/tools/plugins/com.google.dart.engine.services/src/com/google/dart/engine/services/internal/refactoring/RenameRefactoringImpl.java b/editor/tools/plugins/com.google.dart.engine.services/src/com/google/dart/engine/services/internal/refactoring/RenameRefactoringImpl.java
index f791619b8be5432080e1d5c4dbeb5f4c7aa55640..83be2306f854b21f9a0886d6040b7bfee13f72f6 100644
--- a/editor/tools/plugins/com.google.dart.engine.services/src/com/google/dart/engine/services/internal/refactoring/RenameRefactoringImpl.java
+++ b/editor/tools/plugins/com.google.dart.engine.services/src/com/google/dart/engine/services/internal/refactoring/RenameRefactoringImpl.java
@@ -15,6 +15,8 @@
package com.google.dart.engine.services.internal.refactoring;
import com.google.common.base.Objects;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
import com.google.dart.engine.element.Element;
import com.google.dart.engine.element.LocalElement;
import com.google.dart.engine.formatter.edit.Edit;
@@ -30,11 +32,13 @@ import com.google.dart.engine.utilities.source.SourceRange;
import static com.google.dart.engine.utilities.source.SourceRangeFactory.rangeElementName;
+import java.util.List;
+import java.util.Set;
+
/**
* Abstract implementation of {@link RenameRefactoring}.
*/
public abstract class RenameRefactoringImpl extends RefactoringImpl implements RenameRefactoring {
-
/**
* @return the {@link Edit} to replace the given {@link SearchMatch} reference.
*/
@@ -43,6 +47,19 @@ public abstract class RenameRefactoringImpl extends RefactoringImpl implements R
}
/**
+ * When one {@link Source} (one file) is used in more than one context, {@link SearchEngine} will
+ * return separate {@link SearchMatch} for each context. But in rename refactoring we want to
+ * update {@link Source} only once.
+ */
+ protected static List<SearchMatch> getUniqueMatches(List<SearchMatch> matches) {
+ Set<SearchMatch> uniqueMatches = Sets.newHashSet();
+ for (SearchMatch match : matches) {
+ uniqueMatches.add(match);
+ }
+ return Lists.newArrayList(uniqueMatches);
+ }
+
+ /**
* @return {@code true} if two given {@link Element}s are {@link LocalElement}s and have
* intersecting with visibility ranges.
*/

Powered by Google App Engine
This is Rietveld 408576698