Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Vogel2019-06-18 05:16:23 -0400
committerLars Vogel2019-06-18 05:16:23 -0400
commitd5d2e9d7beddcef698e9dfd70de89e7d63c89524 (patch)
tree5c8344940169381dd24400dda2f16ea7f6daa99a
parent0af9ea510f9c3d39e0ad400aac48d22c54a95784 (diff)
downloadeclipse.platform.team-d5d2e9d7beddcef698e9dfd70de89e7d63c89524.tar.gz
eclipse.platform.team-d5d2e9d7beddcef698e9dfd70de89e7d63c89524.tar.xz
eclipse.platform.team-d5d2e9d7beddcef698e9dfd70de89e7d63c89524.zip
Use addAll, deleteAll instead of looping through a collectionI20190618-1805
Change-Id: If74eec05fb721ceeb1f9f8d7fbac9d68be6e767f Signed-off-by: Lars Vogel <Lars.Vogel@vogella.com>
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/EditionSelectionDialog.java5
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/DocumentMerger.java5
-rw-r--r--bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/proxy/win32/winhttp/StaticProxyConfig.java5
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/core/diff/provider/DiffTree.java5
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/ResourceMappingMerger.java5
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/provider/SynchronizationScopeManager.java5
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/mapping/ScopeChangeEvent.java9
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/mapping/ScopeManagerEventHandler.java5
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/ActiveChangeSetManager.java5
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/BatchingChangeSetManager.java9
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/DescendantResourceVariantByteStore.java5
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/SyncFileChangeListener.java5
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSLightweightDecorator.java4
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/CVSModelProviderAction.java4
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ChangeSetActionProvider.java4
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ChangeSetContentProvider.java12
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ChangeSetLabelProvider.java5
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/CheckedInChangeSetCollector.java4
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryRoot.java4
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/SingleFileTagSource.java5
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/Utils.java5
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/CompareInputChangeNotifier.java5
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ResourceMergeActionHandler.java5
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ResourceModelProviderOperation.java5
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ResourceModelTraversalCalculator.java9
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/SynchronizationResourceMappingContext.java5
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/AbstractSynchronizeModelProvider.java13
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/CompositeModelProvider.java5
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeModelUpdateHandler.java4
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ExportProjectSetMainPage.java9
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/mapping/SynchronizationContentProvider.java9
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ModelSynchronizeParticipant.java5
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ModelProject.java5
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/mapping/ModResourceMapping.java9
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/mapping/ModelMerger.java5
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/PessimisticModificationValidator.java5
-rw-r--r--tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/ResourceContentTests.java5
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/mappings/model/ModelProject.java5
38 files changed, 79 insertions, 144 deletions
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/EditionSelectionDialog.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/EditionSelectionDialog.java
index 2a8c0e553..0e6ae5aa2 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/EditionSelectionDialog.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/EditionSelectionDialog.java
@@ -15,6 +15,7 @@ package org.eclipse.compare;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
@@ -466,9 +467,7 @@ public class EditionSelectionDialog extends ResizableDialog {
if (sco != null) {
Object[] children= sco.getChildren();
if (children != null)
- for (Object child : children) {
- current.add(child);
- }
+ Collections.addAll(current, children);
}
final IStructureCreator sc= structureCreator;
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/DocumentMerger.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/DocumentMerger.java
index e34d14653..8828ab25f 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/DocumentMerger.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/DocumentMerger.java
@@ -16,6 +16,7 @@ package org.eclipse.compare.internal.merge;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.Iterator;
import java.util.List;
@@ -1122,9 +1123,7 @@ public class DocumentMerger {
List<Diff> intersectingDiffs = new ArrayList<>();
for (Diff diff : fChangeDiffs) {
Diff[] changeDiffs = diff.getChangeDiffs(contributor, region);
- for (Diff changeDiff : changeDiffs) {
- intersectingDiffs.add(changeDiff);
- }
+ Collections.addAll(intersectingDiffs, changeDiffs);
}
return intersectingDiffs.toArray(new Diff[intersectingDiffs.size()]);
}
diff --git a/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/proxy/win32/winhttp/StaticProxyConfig.java b/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/proxy/win32/winhttp/StaticProxyConfig.java
index e1c0d08e3..9632a371e 100644
--- a/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/proxy/win32/winhttp/StaticProxyConfig.java
+++ b/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/proxy/win32/winhttp/StaticProxyConfig.java
@@ -17,6 +17,7 @@ package org.eclipse.core.internal.net.proxy.win32.winhttp;
import java.net.URI;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -83,9 +84,7 @@ public class StaticProxyConfig {
}
}
} else {
- for (IProxyData d : data) {
- proxies.add(d);
- }
+ Collections.addAll(proxies, data);
}
}
}
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/diff/provider/DiffTree.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/diff/provider/DiffTree.java
index 5cb113a49..3405624cd 100644
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/diff/provider/DiffTree.java
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/diff/provider/DiffTree.java
@@ -13,6 +13,7 @@
*******************************************************************************/
package org.eclipse.team.core.diff.provider;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
@@ -368,9 +369,7 @@ public class DiffTree implements IDiffTree {
changes = new HashSet<>();
propertyChanges.put(key, changes);
}
- for (IPath path : paths) {
- changes.add(path);
- }
+ Collections.addAll(changes, paths);
}
@Override
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/ResourceMappingMerger.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/ResourceMappingMerger.java
index 702087800..ad9345fca 100644
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/ResourceMappingMerger.java
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/ResourceMappingMerger.java
@@ -13,6 +13,7 @@
*******************************************************************************/
package org.eclipse.team.core.mapping;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@@ -106,9 +107,7 @@ public abstract class ResourceMappingMerger implements IResourceMappingMerger {
for (ResourceMapping mapping : mappings) {
ResourceTraversal[] traversals = mergeContext.getScope().getTraversals(mapping);
IDiff[] deltas = mergeContext.getDiffTree().getDiffs(traversals);
- for (IDiff delta : deltas) {
- result.add(delta);
- }
+ Collections.addAll(result, deltas);
}
return result.toArray(new IDiff[result.size()]);
}
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/provider/SynchronizationScopeManager.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/provider/SynchronizationScopeManager.java
index b6c694a8e..74773943a 100644
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/provider/SynchronizationScopeManager.java
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/mapping/provider/SynchronizationScopeManager.java
@@ -14,6 +14,7 @@
package org.eclipse.team.core.mapping.provider;
import java.util.Arrays;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@@ -416,9 +417,7 @@ public class SynchronizationScopeManager extends PlatformObject implements ISync
ResourceMapping[] mappings = scope.getMappings();
if (inputMappings.length == mappings.length) {
Set<ResourceMapping> testSet = new HashSet<>();
- for (ResourceMapping mapping : mappings) {
- testSet.add(mapping);
- }
+ Collections.addAll(testSet, mappings);
for (ResourceMapping mapping : inputMappings) {
if (!testSet.contains(mapping)) {
return true;
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/mapping/ScopeChangeEvent.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/mapping/ScopeChangeEvent.java
index cd17a2c9b..aeec497b1 100644
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/mapping/ScopeChangeEvent.java
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/mapping/ScopeChangeEvent.java
@@ -14,6 +14,7 @@
package org.eclipse.team.internal.core.mapping;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -69,9 +70,7 @@ public class ScopeChangeEvent {
// The number of mappings has increased so we should report the new mappings
Set<ResourceMapping> originalSet = new HashSet<>();
List<ResourceMapping> result = new ArrayList<>();
- for (ResourceMapping mapping : originalMappings) {
- originalSet.add(mapping);
- }
+ Collections.addAll(originalSet, originalMappings);
for (ResourceMapping mapping : currentMappings) {
if (!originalSet.contains(mapping)) {
result.add(mapping);
@@ -82,9 +81,7 @@ public class ScopeChangeEvent {
// The number of mappings may be smaller so report the removed mappings
Set<ResourceMapping> finalSet = new HashSet<>();
List<ResourceMapping> result = new ArrayList<>();
- for (ResourceMapping mapping : currentMappings) {
- finalSet.add(mapping);
- }
+ Collections.addAll(finalSet, currentMappings);
for (ResourceMapping mapping : originalMappings) {
if (!finalSet.contains(mapping)) {
result.add(mapping);
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/mapping/ScopeManagerEventHandler.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/mapping/ScopeManagerEventHandler.java
index 271a1f986..95ac2ef9a 100644
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/mapping/ScopeManagerEventHandler.java
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/mapping/ScopeManagerEventHandler.java
@@ -13,6 +13,7 @@
*******************************************************************************/
package org.eclipse.team.internal.core.mapping;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@@ -65,9 +66,7 @@ public class ScopeManagerEventHandler extends BackgroundEventHandler {
throws CoreException {
if (event instanceof ResourceMappingEvent) {
ResourceMappingEvent rme = (ResourceMappingEvent) event;
- for (ResourceMapping mapping : rme.mappings) {
- toRefresh.add(mapping);
- }
+ Collections.addAll(toRefresh, rme.mappings);
}
}
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/ActiveChangeSetManager.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/ActiveChangeSetManager.java
index 307c1978d..c5bf0cdd9 100644
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/ActiveChangeSetManager.java
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/ActiveChangeSetManager.java
@@ -15,6 +15,7 @@
package org.eclipse.team.internal.core.subscribers;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -219,9 +220,7 @@ public abstract class ActiveChangeSetManager extends ChangeSetManager implements
allResources.add(diff.getPath());
}
IPath[] removals = event.getRemovals();
- for (IPath path : removals) {
- allResources.add(path);
- }
+ Collections.addAll(allResources, removals);
return allResources.toArray(new IPath[allResources.size()]);
}
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/BatchingChangeSetManager.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/BatchingChangeSetManager.java
index cd4ad4d80..b7948064d 100644
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/BatchingChangeSetManager.java
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/BatchingChangeSetManager.java
@@ -13,6 +13,7 @@
*******************************************************************************/
package org.eclipse.team.internal.core.subscribers;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
@@ -64,12 +65,8 @@ public class BatchingChangeSetManager extends ChangeSetManager {
changed.put(changeSet, allAffectedResources);
} else {
Set<IPath> allPaths = new HashSet<>();
- for (IPath path : paths) {
- allPaths.add(path);
- }
- for (IPath path : allAffectedResources) {
- allPaths.add(path);
- }
+ Collections.addAll(allPaths, paths);
+ Collections.addAll(allPaths, allAffectedResources);
changed.put(changeSet, allPaths.toArray(new IPath[allPaths.size()]));
}
}
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/DescendantResourceVariantByteStore.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/DescendantResourceVariantByteStore.java
index 49532b35b..5a333ccdc 100644
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/DescendantResourceVariantByteStore.java
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/DescendantResourceVariantByteStore.java
@@ -13,6 +13,7 @@
*******************************************************************************/
package org.eclipse.team.internal.core.subscribers;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@@ -155,9 +156,7 @@ public abstract class DescendantResourceVariantByteStore extends ResourceVariant
IResource[] remoteMembers = getRemoteStore().members(resource);
IResource[] baseMembers = getBaseStore().members(resource);
Set<IResource> members = new HashSet<>();
- for (IResource remoteMember : remoteMembers) {
- members.add(remoteMember);
- }
+ Collections.addAll(members, remoteMembers);
for (IResource member : baseMembers) {
// Add the base only if the remote does not know about it
// (i.e. hasn't marked it as deleted
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/SyncFileChangeListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/SyncFileChangeListener.java
index e81337326..3255a5d69 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/SyncFileChangeListener.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/SyncFileChangeListener.java
@@ -13,6 +13,7 @@
*******************************************************************************/
package org.eclipse.team.internal.ccvs.core.util;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@@ -133,9 +134,7 @@ public class SyncFileChangeListener implements IResourceChangeListener {
if(isMetaFile(resource)) {
IResource[] toBeNotified = handleChangedMetaFile(resource);
if(toBeNotified.length>0 && isModifiedBy3rdParty(resource)) {
- for (IResource t : toBeNotified) {
- changedContainers.add(t);
- }
+ Collections.addAll(changedContainers, toBeNotified);
if(Policy.DEBUG_METAFILE_CHANGES) {
System.out.println("[cvs] metafile changed by 3rd party: " + resource.getFullPath()); //$NON-NLS-1$
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSLightweightDecorator.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSLightweightDecorator.java
index 40ffd361b..58ddc939b 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSLightweightDecorator.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSLightweightDecorator.java
@@ -260,9 +260,7 @@ public class CVSLightweightDecorator extends LabelProvider implements ILightweig
ResourceTraversal[] traversals = mapping.getTraversals(ResourceMappingContext.LOCAL_CONTEXT, null);
for (ResourceTraversal traversal : traversals) {
IResource[] resources = traversal.getResources();
- for (IResource resource : resources) {
- result.add(resource);
- }
+ Collections.addAll(result, resources);
}
}
return (IResource[]) result.toArray(new IResource[result.size()]);
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/CVSModelProviderAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/CVSModelProviderAction.java
index b05486035..2d372c95b 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/CVSModelProviderAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/CVSModelProviderAction.java
@@ -79,9 +79,7 @@ public abstract class CVSModelProviderAction extends ResourceModelParticipantAct
ResourceTraversal[] traversals = mapping.getTraversals(ResourceMappingContext.LOCAL_CONTEXT, null);
for (ResourceTraversal traversal : traversals) {
IResource[] resources = traversal.getResources();
- for (IResource resource : resources) {
- roots.add(resource);
- }
+ Collections.addAll(roots, resources);
}
} catch (CoreException e) {
TeamUIPlugin.log(e);
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ChangeSetActionProvider.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ChangeSetActionProvider.java
index b27c5359b..4f627b2b3 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ChangeSetActionProvider.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ChangeSetActionProvider.java
@@ -459,9 +459,7 @@ public class ChangeSetActionProvider extends ResourceModelActionProvider {
List<IDiff> result = new ArrayList<>();
for (TreePath path : paths) {
IDiff[] diffs = getLocalChanges(path);
- for (IDiff diff : diffs) {
- result.add(diff);
- }
+ Collections.addAll(result, diffs);
}
return result.toArray(new IDiff[result.size()]);
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ChangeSetContentProvider.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ChangeSetContentProvider.java
index 8d47e6365..5d5cf9f73 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ChangeSetContentProvider.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ChangeSetContentProvider.java
@@ -545,15 +545,11 @@ public class ChangeSetContentProvider extends ResourceModelContentProvider imple
if (csc.supportsActiveChangeSets()) {
ActiveChangeSetManager collector = csc.getActiveChangeSetManager();
ChangeSet[] sets = collector.getSets();
- for (ChangeSet set : sets) {
- result.add(set);
- }
+ Collections.addAll(result, sets);
}
if (checkedInCollector != null) {
ChangeSet[] sets = checkedInCollector.getSets();
- for (ChangeSet set : sets) {
- result.add(set);
- }
+ Collections.addAll(result, sets);
}
return (DiffChangeSet[]) result.toArray(new DiffChangeSet[result.size()]);
}
@@ -723,9 +719,7 @@ public class ChangeSetContentProvider extends ResourceModelContentProvider imple
Set result = new HashSet();
for (IPath path : paths) {
ChangeSet[] sets = getSetsShowingPropogatedStateFrom(path);
- for (ChangeSet set : sets) {
- result.add(set);
- }
+ Collections.addAll(result, sets);
}
return (ChangeSet[]) result.toArray(new ChangeSet[result.size()]);
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ChangeSetLabelProvider.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ChangeSetLabelProvider.java
index be2d5f664..6ac04cb56 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ChangeSetLabelProvider.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ChangeSetLabelProvider.java
@@ -13,6 +13,7 @@
*******************************************************************************/
package org.eclipse.team.internal.ccvs.ui.mappings;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@@ -174,9 +175,7 @@ public class ChangeSetLabelProvider extends ResourceModelLabelProvider {
if (object instanceof IProject) {
IProject project = (IProject) object;
ChangeSet[] sets = getSetsContaing(project);
- for (ChangeSet set : sets) {
- result.add(set);
- }
+ Collections.addAll(result, sets);
}
}
return result.toArray();
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/CheckedInChangeSetCollector.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/CheckedInChangeSetCollector.java
index 4590d1690..732013119 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/CheckedInChangeSetCollector.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/CheckedInChangeSetCollector.java
@@ -86,9 +86,7 @@ public class CheckedInChangeSetCollector extends BatchingChangeSetManager implem
private IPath[] getAffectedPaths(IDiffChangeEvent event) {
Set<IPath> result = new HashSet<>();
IPath[] removed = event.getRemovals();
- for (IPath path : removed) {
- result.add(path);
- }
+ Collections.addAll(result, removed);
IDiff[] diffs = event.getAdditions();
for (IDiff diff : diffs) {
result.add(diff.getPath());
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryRoot.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryRoot.java
index ad3b107f6..a1790bfd0 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryRoot.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryRoot.java
@@ -496,9 +496,7 @@ public class RepositoryRoot extends PlatformObject {
ILogEntry[] entries = file.getLogEntries(monitor);
for (ILogEntry entry : entries) {
CVSTag[] tags = entry.getTags();
- for (CVSTag tag : tags) {
- tagSet.add(tag);
- }
+ Collections.addAll(tagSet, tags);
}
return tagSet.toArray(new CVSTag[0]);
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/SingleFileTagSource.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/SingleFileTagSource.java
index 9ab4fff58..173a97909 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/SingleFileTagSource.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/SingleFileTagSource.java
@@ -13,6 +13,7 @@
*******************************************************************************/
package org.eclipse.team.internal.ccvs.ui.tags;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@@ -30,9 +31,7 @@ public class SingleFileTagSource extends TagSource {
public static CVSTag[] fetchTagsFor(ICVSFile file, IProgressMonitor monitor) throws TeamException {
Set<CVSTag> tagSet = new HashSet<>();
for (ILogEntry entry : file.getLogEntries(monitor)) {
- for (CVSTag tag : entry.getTags()) {
- tagSet.add(tag);
- }
+ Collections.addAll(tagSet, entry.getTags());
}
return tagSet.toArray(new CVSTag[tagSet.size()]);
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/Utils.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/Utils.java
index df2ad53da..7ea7072ce 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/Utils.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/Utils.java
@@ -18,6 +18,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.Iterator;
@@ -677,9 +678,7 @@ public class Utils {
ResourceTraversal[] traversals = element.getTraversals(ResourceMappingContext.LOCAL_CONTEXT, null);
for (ResourceTraversal traversal : traversals) {
IResource[] resourceArray = traversal.getResources();
- for (IResource resource : resourceArray) {
- resources.add(resource);
- }
+ Collections.addAll(resources, resourceArray);
}
} catch (CoreException e) {
TeamUIPlugin.log(new Status(IStatus.ERROR, TeamUIPlugin.ID, 0, "Error traversing resource mapping", e)); //$NON-NLS-1$
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/CompareInputChangeNotifier.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/CompareInputChangeNotifier.java
index 9c52a1eec..db7fc0229 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/CompareInputChangeNotifier.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/CompareInputChangeNotifier.java
@@ -14,6 +14,7 @@
package org.eclipse.team.internal.ui.mapping;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -133,9 +134,7 @@ public abstract class CompareInputChangeNotifier implements
InputChangeEvent changeEvent = (InputChangeEvent) event;
ICompareInput[] inputs = changeEvent.getChangedInputs();
synchronized (changedInputs) {
- for (ICompareInput input : inputs) {
- changedInputs.add(input);
- }
+ Collections.addAll(changedInputs, inputs);
}
}
break;
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ResourceMergeActionHandler.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ResourceMergeActionHandler.java
index 6a740b220..107cd6ee6 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ResourceMergeActionHandler.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ResourceMergeActionHandler.java
@@ -13,6 +13,7 @@
*******************************************************************************/
package org.eclipse.team.internal.ui.mapping;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@@ -72,9 +73,7 @@ public abstract class ResourceMergeActionHandler extends MergeActionHandler impl
ResourceTraversal[] traversals = mapping.getTraversals(ResourceMappingContext.LOCAL_CONTEXT, null);
for (ResourceTraversal traversal : traversals) {
IResource[] resources = traversal.getResources();
- for (IResource resource : resources) {
- roots.add(resource);
- }
+ Collections.addAll(roots, resources);
}
} catch (CoreException e) {
TeamUIPlugin.log(e);
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ResourceModelProviderOperation.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ResourceModelProviderOperation.java
index b8e8b386b..1dd1494f0 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ResourceModelProviderOperation.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ResourceModelProviderOperation.java
@@ -14,6 +14,7 @@
package org.eclipse.team.internal.ui.mapping;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -61,9 +62,7 @@ public abstract class ResourceModelProviderOperation extends SynchronizationOper
Set<IDiff> result = new HashSet<>();
for (Object pathOrElement : pathOrElements) {
IDiff[] diffs = getFileDeltas(pathOrElement);
- for (IDiff node : diffs) {
- result.add(node);
- }
+ Collections.addAll(result, diffs);
}
return result.toArray(new IDiff[result.size()]);
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ResourceModelTraversalCalculator.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ResourceModelTraversalCalculator.java
index aa1b7dd06..dd95a38d9 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ResourceModelTraversalCalculator.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ResourceModelTraversalCalculator.java
@@ -14,6 +14,7 @@
package org.eclipse.team.internal.ui.mapping;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@@ -161,13 +162,9 @@ public class ResourceModelTraversalCalculator {
private Object[] getTreeChildren(IResourceDiffTree diffTree, IResource resource, Object[] children) {
Set<Object> result = new HashSet<>();
- for (Object object : children) {
- result.add(object);
- }
+ Collections.addAll(result, children);
IResource[] setChildren = getChildren(diffTree, resource);
- for (IResource child : setChildren) {
- result.add(child);
- }
+ Collections.addAll(result, setChildren);
Object[] allChildren = result.toArray(new Object[result.size()]);
return allChildren;
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/SynchronizationResourceMappingContext.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/SynchronizationResourceMappingContext.java
index b4933656a..379c81672 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/SynchronizationResourceMappingContext.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/SynchronizationResourceMappingContext.java
@@ -13,6 +13,7 @@
*******************************************************************************/
package org.eclipse.team.internal.ui.mapping;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@@ -122,9 +123,7 @@ public final class SynchronizationResourceMappingContext extends
public IResource[] fetchMembers(IContainer container, IProgressMonitor monitor) throws CoreException {
Set<IResource> result = new HashSet<>();
IResource[] children = container.members();
- for (IResource resource : children) {
- result.add(resource);
- }
+ Collections.addAll(result, children);
IPath[] childPaths = context.getDiffTree().getChildren(container.getFullPath());
for (IPath path : childPaths) {
IDiff delta = context.getDiffTree().getDiff(path);
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/AbstractSynchronizeModelProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/AbstractSynchronizeModelProvider.java
index 2756ed5c1..2fb028413 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/AbstractSynchronizeModelProvider.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/AbstractSynchronizeModelProvider.java
@@ -14,6 +14,7 @@
package org.eclipse.team.internal.ui.synchronize;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
@@ -414,15 +415,11 @@ public abstract class AbstractSynchronizeModelProvider implements ISynchronizeMo
protected IResource[] getExpandedResources() {
Set<IResource> expanded = new HashSet<>();
IResource[] savedExpansionState = getCachedResources(P_VIEWER_EXPANSION_STATE);
- for (IResource resource : savedExpansionState) {
- expanded.add(resource);
- }
+ Collections.addAll(expanded, savedExpansionState);
StructuredViewer viewer = getViewer();
Object[] objects = ((AbstractTreeViewer) viewer).getVisibleExpandedElements();
IResource[] currentExpansionState = getResources(objects);
- for (IResource resource : currentExpansionState) {
- expanded.add(resource);
- }
+ Collections.addAll(expanded, currentExpansionState);
return expanded.toArray(new IResource[expanded.size()]);
}
@@ -611,9 +608,7 @@ public abstract class AbstractSynchronizeModelProvider implements ISynchronizeMo
ISynchronizeModelElement[] elements = getModelObjects(resource);
// Only expand when there is one element per resource
if (elements.length == 1) {
- for (ISynchronizeModelElement element : elements) {
- checkedElements.add(element);
- }
+ Collections.addAll(checkedElements, elements);
}
}
if (!checkedElements.isEmpty())
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/CompositeModelProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/CompositeModelProvider.java
index dc57dd375..7ce1850d2 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/CompositeModelProvider.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/CompositeModelProvider.java
@@ -14,6 +14,7 @@
package org.eclipse.team.internal.ui.synchronize;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -78,9 +79,7 @@ public abstract class CompositeModelProvider extends AbstractSynchronizeModelPro
for (ISynchronizeModelProvider provider : providers) {
if (provider instanceof AbstractSynchronizeModelProvider) {
ISynchronizeModelElement[] elements = ((AbstractSynchronizeModelProvider)provider).getClosestExistingParents(resource);
- for (ISynchronizeModelElement element : elements) {
- result.add(element);
- }
+ Collections.addAll(result, elements);
}
}
return result.toArray(new ISynchronizeModelElement[result.size()]);
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeModelUpdateHandler.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeModelUpdateHandler.java
index 62c55d288..f9ad69236 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeModelUpdateHandler.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeModelUpdateHandler.java
@@ -182,9 +182,7 @@ public class SynchronizeModelUpdateHandler extends BackgroundEventHandler implem
handledResources.add(resource);
ISynchronizeModelElement[] elements = provider.getClosestExistingParents(delta.getResource());
if (elements != null && elements.length > 0) {
- for (ISynchronizeModelElement element : elements) {
- changes.add(element);
- }
+ Collections.addAll(changes, elements);
}
}
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ExportProjectSetMainPage.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ExportProjectSetMainPage.java
index 3a50b8739..04c8b274f 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ExportProjectSetMainPage.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/wizards/ExportProjectSetMainPage.java
@@ -16,6 +16,7 @@ package org.eclipse.team.internal.ui.wizards;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
@@ -382,9 +383,7 @@ public class ExportProjectSetMainPage extends TeamWizardPage {
IWorkingSet workingSet = (IWorkingSet) temp;
if (event.getChecked()){
IAdaptable[] elements1 = workingSet.getElements();
- for (IAdaptable element : elements1) {
- selectedProjects.add(element);
- }
+ Collections.addAll(selectedProjects, elements1);
} else {
IAdaptable[] elements2 = workingSet.getElements();
for (IAdaptable element : elements2) {
@@ -415,9 +414,7 @@ public class ExportProjectSetMainPage extends TeamWizardPage {
tableViewer.setAllChecked(true);
selectedProjects.removeAll(selectedProjects);
Object[] checked = tableViewer.getCheckedElements();
- for (Object c : checked) {
- selectedProjects.add(c);
- }
+ Collections.addAll(selectedProjects, checked);
updateEnablement();
});
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/mapping/SynchronizationContentProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/mapping/SynchronizationContentProvider.java
index 32cddb510..759e401f8 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/mapping/SynchronizationContentProvider.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/mapping/SynchronizationContentProvider.java
@@ -14,6 +14,7 @@
package org.eclipse.team.ui.mapping;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -504,12 +505,8 @@ public abstract class SynchronizationContentProvider implements ICommonContentPr
if (children.length == 0)
return setChildren;
Set<Object> result = new HashSet<>(children.length);
- for (Object c : children) {
- result.add(c);
- }
- for (IResource s : setChildren) {
- result.add(s);
- }
+ Collections.addAll(result, children);
+ Collections.addAll(result, setChildren);
return result.toArray();
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ModelSynchronizeParticipant.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ModelSynchronizeParticipant.java
index ca6d731bb..d58d58b73 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ModelSynchronizeParticipant.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ModelSynchronizeParticipant.java
@@ -15,6 +15,7 @@ package org.eclipse.team.ui.synchronize;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import org.eclipse.compare.structuremergeviewer.ICompareInput;
@@ -519,9 +520,7 @@ public class ModelSynchronizeParticipant extends
ISynchronizationCompareAdapter adapter = Utils.getCompareAdapter(provider);
if (adapter != null) {
ResourceMapping[] mappings = adapter.restore(memento.getChild(CTX_MODEL_PROVIDER_MAPPINGS));
- for (ResourceMapping mapping : mappings) {
- result.add(mapping);
- }
+ Collections.addAll(result, mappings);
}
} catch (CoreException e) {
TeamUIPlugin.log(e);
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ModelProject.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ModelProject.java
index 00aa326fe..13acce31b 100644
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ModelProject.java
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ModelProject.java
@@ -14,6 +14,7 @@
package org.eclipse.team.examples.model;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import org.eclipse.core.resources.IProject;
@@ -34,9 +35,7 @@ public class ModelProject extends ModelContainer {
IProjectDescription description = project.getDescription();
String[] natureIds = description.getNatureIds();
List<String> result = new ArrayList<>();
- for (String natureId : natureIds) {
- result.add(natureId);
- }
+ Collections.addAll(result, natureIds);
result.add(ModelNature.NATURE_ID);
description.setNatureIds(result.toArray(new String[result.size()]));
project.setDescription(description, monitor);
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/mapping/ModResourceMapping.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/mapping/ModResourceMapping.java
index 02d97dcc4..a2d8dde82 100644
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/mapping/ModResourceMapping.java
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/mapping/ModResourceMapping.java
@@ -13,6 +13,7 @@
*******************************************************************************/
package org.eclipse.team.examples.model.mapping;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@@ -49,9 +50,7 @@ public class ModResourceMapping extends ModelResourceMapping {
getResource().getProject().getName(),
remoteContext.fetchRemoteContents((IFile)getResource(),
SubMonitor.convert(monitor, IProgressMonitor.UNKNOWN)));
- for (IResource resource : remoteResources) {
- resources.add(resource);
- }
+ Collections.addAll(resources, remoteResources);
}
if (remoteContext.isThreeWay()
&& remoteContext.hasLocalChange(getResource(), SubMonitor.convert(monitor, IProgressMonitor.UNKNOWN))) {
@@ -59,9 +58,7 @@ public class ModResourceMapping extends ModelResourceMapping {
getResource().getProject().getName(),
remoteContext.fetchBaseContents((IFile)getResource(),
SubMonitor.convert(monitor, IProgressMonitor.UNKNOWN)));
- for (IResource resource : remoteResources) {
- resources.add(resource);
- }
+ Collections.addAll(resources, remoteResources);
}
monitor.done();
}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/mapping/ModelMerger.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/mapping/ModelMerger.java
index 6dc403b0e..44b75dca4 100644
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/mapping/ModelMerger.java
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/mapping/ModelMerger.java
@@ -15,6 +15,7 @@ package org.eclipse.team.examples.model.mapping;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
@@ -262,9 +263,7 @@ public class ModelMerger extends ResourceMappingMerger {
private IResource[] getAddedElements(IResource[] baseElements, IResource[] remoteElements) {
List<IResource> result = new ArrayList<>();
Set<IResource> base = new HashSet<>();
- for (IResource resource : baseElements) {
- base.add(resource);
- }
+ Collections.addAll(base, baseElements);
for (IResource resource : remoteElements) {
if (!base.contains(resource))
result.add(resource);
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/PessimisticModificationValidator.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/PessimisticModificationValidator.java
index 1fb183f2b..3fb5f1ff2 100644
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/PessimisticModificationValidator.java
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/PessimisticModificationValidator.java
@@ -13,6 +13,7 @@
*******************************************************************************/
package org.eclipse.team.examples.pessimistic;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
@@ -242,9 +243,7 @@ extends FileModificationValidator {
if (status == Window.OK) {
Object[] results= dialog.getResult();
result[0] = new HashSet(results.length);
- for (Object result2 : results) {
- result[0].add(result2);
- }
+ Collections.addAll(result[0], results);
} else if(status == Window.CANCEL) {
statusCode[0] = IStatus.CANCEL;
}
diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/ResourceContentTests.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/ResourceContentTests.java
index f4d01f0b6..b37d930a9 100644
--- a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/ResourceContentTests.java
+++ b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/synchronize/ResourceContentTests.java
@@ -14,6 +14,7 @@
package org.eclipse.team.tests.ui.synchronize;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
@@ -101,9 +102,7 @@ public class ResourceContentTests extends TeamTest {
private void assertContentsMatch(IResource[] resources) {
Set paths = getPaths(ResourcesPlugin.getWorkspace().getRoot());
Set<Object> resourceSet = new HashSet<>();
- for (IResource resource : resources) {
- resourceSet.add(resource);
- }
+ Collections.addAll(resourceSet, resources);
for (Iterator iterator = paths.iterator(); iterator.hasNext();) {
TreePath path = (TreePath) iterator.next();
Object o = path.getLastSegment();
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/mappings/model/ModelProject.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/mappings/model/ModelProject.java
index 731e09963..639af6f61 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/mappings/model/ModelProject.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/mappings/model/ModelProject.java
@@ -14,6 +14,7 @@
package org.eclipse.team.tests.ccvs.core.mappings.model;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import org.eclipse.core.resources.IContainer;
@@ -38,9 +39,7 @@ public class ModelProject extends ModelObject {
IProjectDescription description = project.getDescription();
String[] natureIds = description.getNatureIds();
List<String> result = new ArrayList<>();
- for (String natureId : natureIds) {
- result.add(natureId);
- }
+ Collections.addAll(result, natureIds);
result.add(ModelNature.NATURE_ID);
description.setNatureIds(result.toArray(new String[result
.size()]));

Back to the top