1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Improved grouping of changes by eliminating a user-visible layer above

files.
This commit is contained in:
sprigogin 2011-07-14 15:32:17 -07:00
parent b73243870e
commit be06f2dcda

View file

@ -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);
}
}
}