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

Cosmetics.

This commit is contained in:
Sergey Prigogin 2011-01-06 02:27:27 +00:00
parent 67cb94a163
commit a5a8d0ed20

View file

@ -9,7 +9,6 @@
* Contributors: * Contributors:
* Institute for Software - initial API and implementation * Institute for Software - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring; package org.eclipse.cdt.internal.ui.refactoring;
import java.util.ArrayList; import java.util.ArrayList;
@ -29,23 +28,23 @@ import org.eclipse.cdt.core.dom.rewrite.ASTRewrite;
* @author Mirko Stocker * @author Mirko Stocker
*/ */
public class ModificationCollector { public class ModificationCollector {
// Each translation unit can have only one ASTRewrite
// Each Translationunit can have only one ASTRewrite private final Map<IASTTranslationUnit, ASTRewrite> rewriters =
private final Map<IASTTranslationUnit, ASTRewrite> rewriters = new HashMap<IASTTranslationUnit, ASTRewrite>(); new HashMap<IASTTranslationUnit, ASTRewrite>();
private Collection<CreateFileChange> changes; private Collection<CreateFileChange> changes;
public ASTRewrite rewriterForTranslationUnit(IASTTranslationUnit unit) { public ASTRewrite rewriterForTranslationUnit(IASTTranslationUnit ast) {
if(! rewriters.containsKey(unit)) { if (!rewriters.containsKey(ast)) {
rewriters.put(unit, ASTRewrite.create(unit)); rewriters.put(ast, ASTRewrite.create(ast));
} }
return rewriters.get(unit); return rewriters.get(ast);
} }
// Creating new files doesn't concern the rewriter, the refactorings can add them here as needed. // Creating new files doesn't concern the rewriter, the refactorings can add them here as needed.
public void addFileChange(CreateFileChange change) { public void addFileChange(CreateFileChange change) {
if(changes == null) { if (changes == null) {
changes = new ArrayList<CreateFileChange>(); changes = new ArrayList<CreateFileChange>();
} }
changes.add(change); changes.add(change);
@ -56,11 +55,10 @@ public class ModificationCollector {
CCompositeChange result = new CCompositeChange(""); //$NON-NLS-1$ CCompositeChange result = new CCompositeChange(""); //$NON-NLS-1$
result.markAsSynthetic(); result.markAsSynthetic();
if(changes != null) if (changes != null)
result.addAll(changes.toArray(new Change[changes.size()])); result.addAll(changes.toArray(new Change[changes.size()]));
for (ASTRewrite each : rewriters.values()) { for (ASTRewrite each : rewriters.values()) {
result.add(each.rewriteAST()); result.add(each.rewriteAST());
} }