Skip to main content
summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorsprigogin2011-07-14 18:32:17 -0400
committersprigogin2011-07-14 18:32:17 -0400
commitbe06f2dcda292eb492cee0c6444e0a24f0493826 (patch)
treec344a304951047b6b3cac446b86dca672458e6c8 /core
parentb73243870e5c619805bf607882838fc70a816b98 (diff)
downloadorg.eclipse.cdt-be06f2dcda292eb492cee0c6444e0a24f0493826.tar.gz
org.eclipse.cdt-be06f2dcda292eb492cee0c6444e0a24f0493826.tar.xz
org.eclipse.cdt-be06f2dcda292eb492cee0c6444e0a24f0493826.zip
Improved grouping of changes by eliminating a user-visible layer above
files.
Diffstat (limited to 'core')
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/ModificationCollector.java25
1 files changed, 22 insertions, 3 deletions
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/ModificationCollector.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/ModificationCollector.java
index 09df6e70c3..7a8864b714 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/ModificationCollector.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/ModificationCollector.java
@@ -17,6 +17,7 @@ import java.util.HashMap;
import java.util.Map;
import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.CompositeChange;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.rewrite.ASTRewrite;
@@ -54,13 +55,31 @@ public class ModificationCollector {
CCompositeChange result = new CCompositeChange(""); //$NON-NLS-1$
result.markAsSynthetic();
- if (changes != null)
- result.addAll(changes.toArray(new Change[changes.size()]));
+ if (changes != null) {
+ for (Change change : changes) {
+ addFlattened(change, result);
+ }
+ }
for (ASTRewrite each : rewriters.values()) {
- result.add(each.rewriteAST());
+ Change change = each.rewriteAST();
+ addFlattened(change, result);
}
return result;
}
+
+ /**
+ * If {@code change} is a CompositeChange, merges it into the {@code receiver}, otherwise
+ * adds it to the {@code receiver}.
+ * @param change The change being added.
+ * @param receiver The composite change that receives the addition.
+ */
+ private void addFlattened(Change change, CompositeChange receiver) {
+ if (change instanceof CompositeChange) {
+ receiver.merge((CompositeChange) change);
+ } else {
+ receiver.add(change);
+ }
+ }
}

Back to the top