Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Hammer2019-07-05 14:41:47 -0400
committerCarsten Hammer2019-07-14 14:50:45 -0400
commit6b0bb561af7ecebe0cf6881373c3d00c53bf2cc4 (patch)
treec75d71dd52ca743332e5fa9e9fd6f8dfebb1e235
parentfd878b586ff648618c875415d228f507bea4944d (diff)
downloadrt.equinox.bundles-6b0bb561af7ecebe0cf6881373c3d00c53bf2cc4.tar.gz
rt.equinox.bundles-6b0bb561af7ecebe0cf6881373c3d00c53bf2cc4.tar.xz
rt.equinox.bundles-6b0bb561af7ecebe0cf6881373c3d00c53bf2cc4.zip
Use jdk 5 for-each-loop (registry)
Replace most simple uses of Iterator with a corresponding for-each-loop. Also add missing braces on loops as necessary. Change-Id: I0dcaa50a43e0ff3b450f386dfa856d75bdcb6cbb Signed-off-by: Carsten Hammer <carsten.hammer@t-online.de>
-rw-r--r--bundles/org.eclipse.equinox.registry/META-INF/MANIFEST.MF2
-rw-r--r--bundles/org.eclipse.equinox.registry/pom.xml4
-rw-r--r--bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/adapter/AdapterFactoryProxy.java6
-rw-r--r--bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/adapter/AdapterManagerListener.java22
-rw-r--r--bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/BaseExtensionPointHandle.java4
-rw-r--r--bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ConfigurationElementHandle.java6
-rw-r--r--bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ExtensionsParser.java10
-rw-r--r--bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/KeyedHashSet.java12
-rw-r--r--bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/RegistryChangeEvent.java5
-rw-r--r--bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/RegistryDelta.java6
-rw-r--r--bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/RegistryObjectManager.java23
-rw-r--r--bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/RegistrySupport.java4
-rw-r--r--bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/TableWriter.java51
-rw-r--r--bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/Activator.java9
-rw-r--r--bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/EclipseBundleListener.java25
-rw-r--r--bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/OSGIUtils.java6
-rw-r--r--bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/RegistryCommandProvider.java36
-rw-r--r--bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/RegistryStrategyOSGI.java6
-rw-r--r--bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/dynamichelpers/ExtensionTracker.java10
19 files changed, 127 insertions, 120 deletions
diff --git a/bundles/org.eclipse.equinox.registry/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.registry/META-INF/MANIFEST.MF
index 72b7a42b..04b15fcf 100644
--- a/bundles/org.eclipse.equinox.registry/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.registry/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.equinox.registry;singleton:=true
-Bundle-Version: 3.8.400.qualifier
+Bundle-Version: 3.8.500.qualifier
Bundle-Localization: plugin
Export-Package: org.eclipse.core.internal.adapter;x-internal:=true,
org.eclipse.core.internal.registry;x-friends:="org.eclipse.core.runtime",
diff --git a/bundles/org.eclipse.equinox.registry/pom.xml b/bundles/org.eclipse.equinox.registry/pom.xml
index 0eef38c5..2e8af712 100644
--- a/bundles/org.eclipse.equinox.registry/pom.xml
+++ b/bundles/org.eclipse.equinox.registry/pom.xml
@@ -5,7 +5,7 @@
are made available under the terms of the Eclipse Distribution License v1.0
which accompanies this distribution, and is available at
http://www.eclipse.org/org/documents/edl-v10.php
-
+
Contributors:
Igor Fedorenko - initial implementation
-->
@@ -19,6 +19,6 @@
</parent>
<groupId>org.eclipse.equinox</groupId>
<artifactId>org.eclipse.equinox.registry</artifactId>
- <version>3.8.400-SNAPSHOT</version>
+ <version>3.8.500-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/adapter/AdapterFactoryProxy.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/adapter/AdapterFactoryProxy.java
index 4bb39c62..a5d0030f 100644
--- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/adapter/AdapterFactoryProxy.java
+++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/adapter/AdapterFactoryProxy.java
@@ -96,10 +96,10 @@ class AdapterFactoryProxy implements IAdapterFactory, IAdapterFactoryExt {
public String[] getAdapterNames() {
IConfigurationElement[] children = element.getChildren();
ArrayList<String> adapters = new ArrayList<>(children.length);
- for (int i = 0; i < children.length; i++) {
+ for (IConfigurationElement child : children) {
//ignore unknown children for forward compatibility
- if ("adapter".equals(children[i].getName())) { //$NON-NLS-1$
- String type = children[i].getAttribute("type"); //$NON-NLS-1$
+ if ("adapter".equals(child.getName())) {//$NON-NLS-1$
+ String type = child.getAttribute("type"); //$NON-NLS-1$
if (type != null)
adapters.add(type);
}
diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/adapter/AdapterManagerListener.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/adapter/AdapterManagerListener.java
index 31acc24f..688b22cb 100644
--- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/adapter/AdapterManagerListener.java
+++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/adapter/AdapterManagerListener.java
@@ -49,10 +49,10 @@ public final class AdapterManagerListener implements IRegistryEventListener, IAd
boolean factoriesAdded = false;
IExtension[] extensions = point.getExtensions();
- for (int i = 0; i < extensions.length; i++) {
- IConfigurationElement[] elements = extensions[i].getConfigurationElements();
- for (int j = 0; j < elements.length; j++) {
- AdapterFactoryProxy proxy = AdapterFactoryProxy.createProxy(elements[j]);
+ for (IExtension extension : extensions) {
+ IConfigurationElement[] elements = extension.getConfigurationElements();
+ for (IConfigurationElement element : elements) {
+ AdapterFactoryProxy proxy = AdapterFactoryProxy.createProxy(element);
if (proxy != null) {
adapterManager.registerFactory(proxy, proxy.getAdaptableType());
factoriesAdded = true;
@@ -65,8 +65,8 @@ public final class AdapterManagerListener implements IRegistryEventListener, IAd
private void registerExtension(IExtension extension) {
IConfigurationElement[] elements = extension.getConfigurationElements();
- for (int j = 0; j < elements.length; j++) {
- AdapterFactoryProxy proxy = AdapterFactoryProxy.createProxy(elements[j]);
+ for (IConfigurationElement element : elements) {
+ AdapterFactoryProxy proxy = AdapterFactoryProxy.createProxy(element);
if (proxy != null)
theAdapterManager.registerFactory(proxy, proxy.getAdaptableType());
}
@@ -74,22 +74,24 @@ public final class AdapterManagerListener implements IRegistryEventListener, IAd
@Override
public synchronized void added(IExtension[] extensions) {
- for (int i = 0; i < extensions.length; i++)
- registerExtension(extensions[i]);
+ for (IExtension extension : extensions) {
+ registerExtension(extension);
+ }
theAdapterManager.flushLookup();
}
@Override
public synchronized void removed(IExtension[] extensions) {
theAdapterManager.flushLookup();
- for (int i = 0; i < extensions.length; i++) {
+ for (IExtension extension : extensions) {
for (Iterator<List<IAdapterFactory>> it = theAdapterManager.getFactories().values().iterator(); it.hasNext();) {
for (Iterator<IAdapterFactory> it2 = (it.next()).iterator(); it2.hasNext();) {
IAdapterFactory factory = it2.next();
if (!(factory instanceof AdapterFactoryProxy))
continue;
- if (((AdapterFactoryProxy) factory).originatesFrom(extensions[i]))
+ if (((AdapterFactoryProxy) factory).originatesFrom(extension)) {
it2.remove();
+ }
}
}
}
diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/BaseExtensionPointHandle.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/BaseExtensionPointHandle.java
index 89abdf44..995a1538 100644
--- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/BaseExtensionPointHandle.java
+++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/BaseExtensionPointHandle.java
@@ -77,8 +77,8 @@ public class BaseExtensionPointHandle extends Handle implements IExtensionPoint
return ConfigurationElementHandle.EMPTY_ARRAY;
ArrayList<Handle> result = new ArrayList<>();
- for (int i = 0; i < tmpExtensions.length; i++) {
- result.addAll(Arrays.asList(objectManager.getHandles(tmpExtensions[i].getRawChildren(), RegistryObjectManager.CONFIGURATION_ELEMENT)));
+ for (Extension tmpExtension : tmpExtensions) {
+ result.addAll(Arrays.asList(objectManager.getHandles(tmpExtension.getRawChildren(), RegistryObjectManager.CONFIGURATION_ELEMENT)));
}
return result.toArray(new IConfigurationElement[result.size()]);
}
diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ConfigurationElementHandle.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ConfigurationElementHandle.java
index 6821179c..6322f0de 100644
--- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ConfigurationElementHandle.java
+++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ConfigurationElementHandle.java
@@ -83,14 +83,14 @@ public class ConfigurationElementHandle extends Handle implements IConfiguration
IConfigurationElement[] result = new IConfigurationElement[1];
int idx = 0;
- for (int i = 0; i < children.length; i++) {
- if (children[i].getName().equals(name)) {
+ for (ConfigurationElement child : children) {
+ if (child.getName().equals(name)) {
if (idx != 0) {
IConfigurationElement[] copy = new IConfigurationElement[result.length + 1];
System.arraycopy(result, 0, copy, 0, result.length);
result = copy;
}
- result[idx++] = (IConfigurationElement) objectManager.getHandle(children[i].getObjectId(), actualCE.noExtraData() ? RegistryObjectManager.CONFIGURATION_ELEMENT : RegistryObjectManager.THIRDLEVEL_CONFIGURATION_ELEMENT);
+ result[idx++] = (IConfigurationElement) objectManager.getHandle(child.getObjectId(), actualCE.noExtraData() ? RegistryObjectManager.CONFIGURATION_ELEMENT : RegistryObjectManager.THIRDLEVEL_CONFIGURATION_ELEMENT);
}
}
if (idx == 0)
diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ExtensionsParser.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ExtensionsParser.java
index 8a840764..f393203a 100644
--- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ExtensionsParser.java
+++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ExtensionsParser.java
@@ -229,8 +229,8 @@ public class ExtensionsParser extends DefaultHandler {
if (extensions.size() > 0) {
Extension[] renamedExtensions = fixRenamedExtensionPoints(extensions.toArray(new Extension[extensions.size()]));
namespaceChildren[Contribution.EXTENSION] = renamedExtensions.length;
- for (int i = 0; i < renamedExtensions.length; i++) {
- namespaceChildren[position++] = renamedExtensions[i].getObjectId();
+ for (Extension renamedExtension : renamedExtensions) {
+ namespaceChildren[position++] = renamedExtension.getObjectId();
}
extensions.clear();
}
@@ -302,8 +302,7 @@ public class ExtensionsParser extends DefaultHandler {
* Remove all elements that we have added so far into registry manager
*/
private void cleanup() {
- for (Iterator<RegistryObject> i = addedRegistryObjects.iterator(); i.hasNext();) {
- RegistryObject object = i.next();
+ for (RegistryObject object : addedRegistryObjects) {
if (object instanceof ExtensionPoint) {
String id = ((ExtensionPoint) object).getUniqueIdentifier();
objectManager.removeExtensionPoint(id);
@@ -694,8 +693,7 @@ public class ExtensionsParser extends DefaultHandler {
private Extension[] fixRenamedExtensionPoints(Extension[] extensions) {
if (extensions == null || versionAtLeast(VERSION_3_0) || RegistryProperties.getProperty(NO_EXTENSION_MUNGING) != null)
return extensions;
- for (int i = 0; i < extensions.length; i++) {
- Extension extension = extensions[i];
+ for (Extension extension : extensions) {
String oldPointId = extension.getExtensionPointIdentifier();
String newPointId = extensionPointMap.get(oldPointId);
if (newPointId != null) {
diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/KeyedHashSet.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/KeyedHashSet.java
index f776ca3c..5eabbcaa 100644
--- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/KeyedHashSet.java
+++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/KeyedHashSet.java
@@ -97,8 +97,7 @@ public class KeyedHashSet {
public Object[] elements(Object[] result) {
int j = 0;
- for (int i = 0; i < elements.length; i++) {
- KeyedElement element = elements[i];
+ for (KeyedElement element : elements) {
if (element != null)
result[j++] = element;
}
@@ -114,8 +113,7 @@ public class KeyedHashSet {
elements = new KeyedElement[elements.length * 2];
int maxArrayIndex = elements.length - 1;
- for (int i = 0; i < oldElements.length; i++) {
- KeyedElement element = oldElements[i];
+ for (KeyedElement element : oldElements) {
if (element != null) {
int hash = hash(element);
while (elements[hash] != null) {
@@ -305,13 +303,13 @@ public class KeyedHashSet {
StringBuilder result = new StringBuilder(100);
result.append("{"); //$NON-NLS-1$
boolean first = true;
- for (int i = 0; i < elements.length; i++) {
- if (elements[i] != null) {
+ for (KeyedElement element : elements) {
+ if (element != null) {
if (first)
first = false;
else
result.append(", "); //$NON-NLS-1$
- result.append(elements[i]);
+ result.append(element);
}
}
result.append("}"); //$NON-NLS-1$
diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/RegistryChangeEvent.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/RegistryChangeEvent.java
index 77c51049..909769bb 100644
--- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/RegistryChangeEvent.java
+++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/RegistryChangeEvent.java
@@ -53,8 +53,9 @@ public final class RegistryChangeEvent implements IRegistryChangeEvent {
if (hostDeltas.length == 0)
return new IExtensionDelta[0];
int extensionDeltasSize = 0;
- for (int i = 0; i < hostDeltas.length; i++)
- extensionDeltasSize += hostDeltas[i].getExtensionDeltasCount();
+ for (RegistryDelta hostDelta : hostDeltas) {
+ extensionDeltasSize += hostDelta.getExtensionDeltasCount();
+ }
IExtensionDelta[] extensionDeltas = new IExtensionDelta[extensionDeltasSize];
for (int i = 0, offset = 0; i < hostDeltas.length; i++) {
IExtensionDelta[] hostExtDeltas = hostDeltas[i].getExtensionDeltas();
diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/RegistryDelta.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/RegistryDelta.java
index 37ad718c..38145b50 100644
--- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/RegistryDelta.java
+++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/RegistryDelta.java
@@ -38,8 +38,7 @@ public class RegistryDelta {
public IExtensionDelta[] getExtensionDeltas(String extensionPoint) {
Collection<IExtensionDelta> selectedExtDeltas = new LinkedList<>();
- for (Iterator<IExtensionDelta> extDeltasIter = extensionDeltas.iterator(); extDeltasIter.hasNext();) {
- IExtensionDelta extensionDelta = extDeltasIter.next();
+ for (IExtensionDelta extensionDelta : extensionDeltas) {
if (extensionDelta.getExtension().getExtensionPointUniqueIdentifier().equals(extensionPoint))
selectedExtDeltas.add(extensionDelta);
}
@@ -51,8 +50,7 @@ public class RegistryDelta {
* @param extensionId must not be null
*/
public IExtensionDelta getExtensionDelta(String extensionPointId, String extensionId) {
- for (Iterator<IExtensionDelta> extDeltasIter = extensionDeltas.iterator(); extDeltasIter.hasNext();) {
- IExtensionDelta extensionDelta = extDeltasIter.next();
+ for (IExtensionDelta extensionDelta : extensionDeltas) {
IExtension extension = extensionDelta.getExtension();
if (extension.getExtensionPointUniqueIdentifier().equals(extensionPointId) && extension.getUniqueIdentifier() != null && extension.getUniqueIdentifier().equals(extensionId))
return extensionDelta;
diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/RegistryObjectManager.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/RegistryObjectManager.java
index 8dac9a96..92bf7562 100644
--- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/RegistryObjectManager.java
+++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/RegistryObjectManager.java
@@ -136,8 +136,7 @@ public class RegistryObjectManager implements IObjectManager {
// Also can return null if empty array is passed in or objects are of an unexpected type
private String findCommonNamespaceIdentifier(RegistryObject[] registryObjects) {
String namespaceName = null;
- for (int i = 0; i < registryObjects.length; i++) {
- RegistryObject currentObject = registryObjects[i];
+ for (RegistryObject currentObject : registryObjects) {
String tmp = null;
if (currentObject instanceof ExtensionPoint)
tmp = ((ExtensionPoint) currentObject).getNamespace();
@@ -687,8 +686,7 @@ public class RegistryObjectManager implements IObjectManager {
*/
synchronized void addNavigableObjects(Map<Integer, RegistryObject> associatedObjects) {
Map<Integer, RegistryObject> result = new HashMap<>();
- for (Iterator<RegistryObject> iter = associatedObjects.values().iterator(); iter.hasNext();) {
- RegistryObject object = iter.next();
+ for (RegistryObject object : associatedObjects.values()) {
if (object instanceof Extension) {
// add extension point
ExtensionPoint extPoint = getExtensionPointObject(((Extension) object).getExtensionPointIdentifier());
@@ -750,9 +748,9 @@ public class RegistryObjectManager implements IObjectManager {
private void collectChildren(RegistryObject ce, int level, Map<Integer, RegistryObject> collector) {
ConfigurationElement[] children = (ConfigurationElement[]) getObjects(ce.getRawChildren(), level == 0 || ce.noExtraData() ? RegistryObjectManager.CONFIGURATION_ELEMENT : RegistryObjectManager.THIRDLEVEL_CONFIGURATION_ELEMENT);
- for (int j = 0; j < children.length; j++) {
- collector.put(Integer.valueOf(children[j].getObjectId()), children[j]);
- collectChildren(children[j], level + 1, collector);
+ for (ConfigurationElement child : children) {
+ collector.put(Integer.valueOf(child.getObjectId()), child);
+ collectChildren(child, level + 1, collector);
}
}
@@ -767,8 +765,8 @@ public class RegistryObjectManager implements IObjectManager {
// Called from a synchronized method only
private boolean unlinkChildFromContributions(KeyedElement[] contributions, int id) {
- for (int i = 0; i < contributions.length; i++) {
- Contribution candidate = (Contribution) contributions[i];
+ for (KeyedElement contribution : contributions) {
+ Contribution candidate = (Contribution) contribution;
if (candidate == null)
continue;
if (candidate.hasChild(id)) {
@@ -801,9 +799,10 @@ public class RegistryObjectManager implements IObjectManager {
// filter extensions with no extension point (orphan extensions)
List<Handle> tmp = new ArrayList<>();
Extension[] exts = (Extension[]) getObjects(namespaceExtensions, EXTENSION);
- for (int i = 0; i < exts.length; i++) {
- if (getExtensionPointObject(exts[i].getExtensionPointIdentifier()) != null)
- tmp.add(getHandle(exts[i].getObjectId(), EXTENSION));
+ for (Extension ext : exts) {
+ if (getExtensionPointObject(ext.getExtensionPointIdentifier()) != null) {
+ tmp.add(getHandle(ext.getObjectId(), EXTENSION));
+ }
}
if (tmp.size() == 0)
return EMPTY_EXTENSIONS_ARRAY;
diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/RegistrySupport.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/RegistrySupport.java
index 203e14b0..112672c3 100644
--- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/RegistrySupport.java
+++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/RegistrySupport.java
@@ -75,8 +75,8 @@ public class RegistrySupport {
newPrefix = "\t"; //$NON-NLS-1$
else
newPrefix = prefix + "\t"; //$NON-NLS-1$
- for (int i = 0; i < children.length; i++) {
- log(children[i], newPrefix);
+ for (IStatus child : children) {
+ log(child, newPrefix);
}
}
}
diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/TableWriter.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/TableWriter.java
index 617548c4..11545e15 100644
--- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/TableWriter.java
+++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/TableWriter.java
@@ -143,8 +143,8 @@ public class TableWriter {
private void saveExtensionRegistry(long timestamp) throws IOException {
ExtensionPointHandle[] points = objectManager.getExtensionPointsHandles();
offsets = new OffsetTable(objectManager.getNextId());
- for (int i = 0; i < points.length; i++) {
- saveExtensionPoint(points[i]);
+ for (ExtensionPointHandle point : points) {
+ saveExtensionPoint(point);
}
saveOrphans();
saveContributions(objectManager.getContributions());
@@ -162,25 +162,27 @@ public class TableWriter {
// get count of contributions that will be cached
int cacheSize = 0;
- for (int i = 0; i < newElements.length; i++) {
- if (((Contribution) newElements[i]).shouldPersist())
+ for (KeyedElement newElement : newElements) {
+ if (((Contribution) newElement).shouldPersist()) {
cacheSize++;
+ }
}
- for (int i = 0; i < formerElements.length; i++) {
- if (((Contribution) formerElements[i]).shouldPersist())
+ for (KeyedElement formerElement : formerElements) {
+ if (((Contribution) formerElement).shouldPersist()) {
cacheSize++;
+ }
}
outputNamespace.writeInt(cacheSize);
- for (int i = 0; i < newElements.length; i++) {
- Contribution element = (Contribution) newElements[i];
+ for (KeyedElement newElement : newElements) {
+ Contribution element = (Contribution) newElement;
if (element.shouldPersist()) {
writeStringOrNull(element.getContributorId(), outputNamespace);
saveArray(filterContributionChildren(element), outputNamespace);
}
}
- for (int i = 0; i < formerElements.length; i++) {
- Contribution element = (Contribution) formerElements[i];
+ for (KeyedElement formerElement : formerElements) {
+ Contribution element = (Contribution) formerElement;
if (element.shouldPersist()) {
writeStringOrNull(element.getContributorId(), outputNamespace);
saveArray(filterContributionChildren(element), outputNamespace);
@@ -211,8 +213,8 @@ public class TableWriter {
KeyedElement[] cachedElements = new KeyedElement[elements.length];
int cacheSize = 0;
- for (int i = 0; i < elements.length; i++) {
- RegistryIndexElement element = (RegistryIndexElement) elements[i];
+ for (KeyedElement e : elements) {
+ RegistryIndexElement element = (RegistryIndexElement) e;
int[] extensionPoints = filter(element.getExtensionPoints());
int[] extensions = filter(element.getExtensions());
if (extensionPoints.length == 0 && extensions.length == 0)
@@ -371,21 +373,21 @@ public class TableWriter {
}
ConfigurationElementHandle[] childrenCEs = (ConfigurationElementHandle[]) element.getChildren();
- for (int i = 0; i < childrenCEs.length; i++) {
- saveConfigurationElement(childrenCEs[i], outputStream, extraOutputStream, depth + 1);
+ for (ConfigurationElementHandle childrenCE : childrenCEs) {
+ saveConfigurationElement(childrenCE, outputStream, extraOutputStream, depth + 1);
}
}
private void saveExtensions(IExtension[] exts, DataOutputStream outputStream) throws IOException {
- for (int i = 0; i < exts.length; i++) {
- saveExtension((ExtensionHandle) exts[i], outputStream);
+ for (IExtension ext : exts) {
+ saveExtension((ExtensionHandle) ext, outputStream);
}
-
- for (int i = 0; i < exts.length; i++) {
- if (!((ExtensionHandle) exts[i]).shouldPersist())
+ for (IExtension ext : exts) {
+ if (!((ExtensionHandle) ext).shouldPersist()) {
continue;
- IConfigurationElement[] ces = exts[i].getConfigurationElements();
+ }
+ IConfigurationElement[] ces = ext.getConfigurationElements();
int countCElements = 0;
boolean[] save = new boolean[ces.length];
for (int j = 0; j < ces.length; j++) {
@@ -436,8 +438,7 @@ public class TableWriter {
private void saveOrphans() throws IOException {
Map<String, int[]> orphans = objectManager.getOrphanExtensions();
Map<String, int[]> filteredOrphans = new HashMap<>();
- for (Iterator<Entry<String, int[]>> iter = orphans.entrySet().iterator(); iter.hasNext();) {
- Entry<String, int[]> entry = iter.next();
+ for (Entry<String, int[]> entry : orphans.entrySet()) {
int[] filteredValue = filter(entry.getValue());
if (filteredValue.length != 0)
filteredOrphans.put(entry.getKey(), filteredValue);
@@ -446,13 +447,11 @@ public class TableWriter {
DataOutputStream outputOrphan = new DataOutputStream(new BufferedOutputStream(fosOrphan));
outputOrphan.writeInt(filteredOrphans.size());
Set<Entry<String, int[]>> elements = filteredOrphans.entrySet();
- for (Iterator<Entry<String, int[]>> iter = elements.iterator(); iter.hasNext();) {
- Entry<String, int[]> entry = iter.next();
+ for (Entry<String, int[]> entry : elements) {
outputOrphan.writeUTF(entry.getKey());
saveArray(entry.getValue(), outputOrphan);
}
- for (Iterator<Entry<String, int[]>> iter = elements.iterator(); iter.hasNext();) {
- Entry<String, int[]> entry = iter.next();
+ for (Entry<String, int[]> entry : elements) {
mainOutput.writeInt(entry.getValue().length);
saveExtensions((IExtension[]) objectManager.getHandles(entry.getValue(), RegistryObjectManager.EXTENSION), mainOutput);
}
diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/Activator.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/Activator.java
index bb178422..628951ea 100644
--- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/Activator.java
+++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/Activator.java
@@ -90,13 +90,14 @@ public class Activator implements BundleActivator {
String[] args = EquinoxUtils.getCommandLine(bundleContext, ref);
if (args == null || args.length == 0)
return;
- for (int i = 0; i < args.length; i++) {
- if (args[i].equalsIgnoreCase(IRegistryConstants.NO_REGISTRY_CACHE))
+ for (String arg : args) {
+ if (arg.equalsIgnoreCase(IRegistryConstants.NO_REGISTRY_CACHE)) {
RegistryProperties.setProperty(IRegistryConstants.PROP_NO_REGISTRY_CACHE, "true"); //$NON-NLS-1$
- else if (args[i].equalsIgnoreCase(IRegistryConstants.NO_LAZY_REGISTRY_CACHE_LOADING))
+ } else if (arg.equalsIgnoreCase(IRegistryConstants.NO_LAZY_REGISTRY_CACHE_LOADING)) {
RegistryProperties.setProperty(IRegistryConstants.PROP_NO_LAZY_CACHE_LOADING, "true"); //$NON-NLS-1$
- else if (args[i].equalsIgnoreCase(IRegistryConstants.MULTI_LANGUAGE))
+ } else if (arg.equalsIgnoreCase(IRegistryConstants.MULTI_LANGUAGE)) {
RegistryProperties.setProperty(IRegistryConstants.PROP_MULTI_LANGUAGE, "true"); //$NON-NLS-1$
+ }
}
}
diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/EclipseBundleListener.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/EclipseBundleListener.java
index 36f4e794..56ec8288 100644
--- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/EclipseBundleListener.java
+++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/EclipseBundleListener.java
@@ -89,11 +89,12 @@ public class EclipseBundleListener implements SynchronousBundleListener {
}
public void processBundles(Bundle[] bundles) {
- for (int i = 0; i < bundles.length; i++) {
- if (isBundleResolved(bundles[i]))
- addBundle(bundles[i], false);
- else
- removeBundle(bundles[i]);
+ for (Bundle bundle : bundles) {
+ if (isBundleResolved(bundle)) {
+ addBundle(bundle, false);
+ } else {
+ removeBundle(bundle);
+ }
}
}
@@ -198,8 +199,9 @@ public class EclipseBundleListener implements SynchronousBundleListener {
if (hosts == null)
return;
// check to see if the hosts should be refreshed because the fragment contains NLS properties files.
- for (int i = 0; i < hosts.length; i++)
- checkForNLSFiles(hosts[i], bundle);
+ for (Bundle host : hosts) {
+ checkForNLSFiles(host, bundle);
+ }
}
private void checkForNLSFiles(Bundle host, Bundle fragment) {
@@ -230,11 +232,12 @@ public class EclipseBundleListener implements SynchronousBundleListener {
// force the host and fragments to be removed and added back
removeBundle(host);
addBundle(host, false);
- for (int i = 0; i < fragments.length; i++) {
- if (fragment.equals(fragments[i]))
+ for (Bundle b : fragments) {
+ if (fragment.equals(b)) {
continue; // skip fragment that was just resolved; it will be added in by the caller
- removeBundle(fragments[i]);
- addBundle(fragments[i], false);
+ }
+ removeBundle(b);
+ addBundle(b, false);
}
synchronized (currentStateStamp) {
// mark this host as processed for the current state stamp.
diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/OSGIUtils.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/OSGIUtils.java
index f951ecee..8015f6a9 100644
--- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/OSGIUtils.java
+++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/OSGIUtils.java
@@ -123,9 +123,9 @@ public class OSGIUtils {
if (bundles == null)
return null;
//Return the first bundle that is not installed or uninstalled
- for (int i = 0; i < bundles.length; i++) {
- if ((bundles[i].getState() & (Bundle.INSTALLED | Bundle.UNINSTALLED)) == 0) {
- return bundles[i];
+ for (Bundle bundle : bundles) {
+ if ((bundle.getState() & (Bundle.INSTALLED | Bundle.UNINSTALLED)) == 0) {
+ return bundle;
}
}
return null;
diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/RegistryCommandProvider.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/RegistryCommandProvider.java
index da756fc6..d51bcc12 100644
--- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/RegistryCommandProvider.java
+++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/RegistryCommandProvider.java
@@ -60,8 +60,9 @@ public class RegistryCommandProvider implements CommandProvider {
String[] namespaces = RegistryFactory.getRegistry().getNamespaces();
ci.println("Namespace(s):"); //$NON-NLS-1$
ci.println("-------------------"); //$NON-NLS-1$
- for (int i = 0; i < namespaces.length; i++)
- ci.println(namespaces[i]);
+ for (String n : namespaces) {
+ ci.println(n);
+ }
return;
}
@@ -69,15 +70,17 @@ public class RegistryCommandProvider implements CommandProvider {
IExtensionPoint[] extpts = registry.getExtensionPoints(namespace);
ci.println("Extension point(s):"); //$NON-NLS-1$
ci.println("-------------------"); //$NON-NLS-1$
- for (int i = 0; i < extpts.length; i++)
- displayExtensionPoint(extpts[i], ci);
+ for (IExtensionPoint extpt : extpts) {
+ displayExtensionPoint(extpt, ci);
+ }
if (verbose) {
ci.println("\nExtension(s):"); //$NON-NLS-1$
ci.println("-------------------"); //$NON-NLS-1$
IExtension[] exts = RegistryFactory.getRegistry().getExtensions(namespace);
- for (int j = 0; j < exts.length; j++)
- displayExtension(exts[j], ci, true /*full*/);
+ for (IExtension ext : exts) {
+ displayExtension(ext, ci, true /*full*/);
+ }
}
}
@@ -93,12 +96,13 @@ public class RegistryCommandProvider implements CommandProvider {
IExtension[] exts = extpt.getExtensions();
ci.println("\nExtension(s):"); //$NON-NLS-1$
ci.println("-------------------"); //$NON-NLS-1$
- for (int i = 0; i < exts.length; i++) {
- displayExtension(exts[i], ci, false /*short*/);
+ for (IExtension ext : exts) {
+ displayExtension(ext, ci, false /*short*/);
if (verbose) {
- IConfigurationElement[] ce = exts[i].getConfigurationElements();
- for (int j = 0; j < ce.length; j++)
- displayConfigElement(ci, ce[j], 1);
+ IConfigurationElement[] ce = ext.getConfigurationElements();
+ for (IConfigurationElement ce1 : ce) {
+ displayConfigElement(ci, ce1, 1);
+ }
ci.println();
}
}
@@ -158,14 +162,16 @@ public class RegistryCommandProvider implements CommandProvider {
String spacing = spacing(ci, level);
ci.println(spacing + '<' + ce.getName() + '>');
String[] attrs = ce.getAttributeNames();
- for (int k = 0; k < attrs.length; k++)
- ci.println(indent + spacing + attrs[k] + " = " + ce.getAttribute(attrs[k])); //$NON-NLS-1$
+ for (String attr : attrs) {
+ ci.println(indent + spacing + attr + " = " + ce.getAttribute(attr)); //$NON-NLS-1$
+ }
String value = ce.getValue();
if (value != null)
ci.println(indent + spacing + value);
IConfigurationElement[] children = ce.getChildren();
- for (int z = 0; z < children.length; z++)
- displayConfigElement(ci, children[z], level + 1);
+ for (IConfigurationElement child : children) {
+ displayConfigElement(ci, child, level + 1);
+ }
ci.println(spacing + "</" + ce.getName() + '>'); //$NON-NLS-1$
}
diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/RegistryStrategyOSGI.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/RegistryStrategyOSGI.java
index f847124c..da998785 100644
--- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/RegistryStrategyOSGI.java
+++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/RegistryStrategyOSGI.java
@@ -290,11 +290,11 @@ public class RegistryStrategyOSGI extends RegistryStrategy {
RegistryTimestamp expectedTimestamp = new RegistryTimestamp();
BundleContext context = Activator.getContext();
Bundle[] allBundles = context.getBundles();
- for (int i = 0; i < allBundles.length; i++) {
- URL pluginManifest = EclipseBundleListener.getExtensionURL(allBundles[i], false);
+ for (Bundle b : allBundles) {
+ URL pluginManifest = EclipseBundleListener.getExtensionURL(b, false);
if (pluginManifest == null)
continue;
- long timestamp = getExtendedTimestamp(allBundles[i], pluginManifest);
+ long timestamp = getExtendedTimestamp(b, pluginManifest);
expectedTimestamp.add(timestamp);
}
return expectedTimestamp.getContentsTimestamp();
diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/dynamichelpers/ExtensionTracker.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/dynamichelpers/ExtensionTracker.java
index 942e54ae..dee661b7 100644
--- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/dynamichelpers/ExtensionTracker.java
+++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/dynamichelpers/ExtensionTracker.java
@@ -151,8 +151,8 @@ public class ExtensionTracker implements IExtensionTracker, IRegistryChangeListe
handlersCopy = handlers.getListeners();
}
- for (int i = 0; i < handlersCopy.length; i++) {
- HandlerWrapper wrapper = (HandlerWrapper) handlersCopy[i];
+ for (Object w : handlersCopy) {
+ HandlerWrapper wrapper = (HandlerWrapper) w;
if (wrapper.filter == null || wrapper.filter.matches(delta.getExtensionPoint())) {
if (objects == null)
applyAdd(wrapper.handler, delta.getExtension());
@@ -277,9 +277,11 @@ public class ExtensionTracker implements IExtensionTracker, IRegistryChangeListe
return new IFilter() {
@Override
public boolean matches(IExtensionPoint target) {
- for (int i = 0; i < xpts.length; i++)
- if (xpts[i].equals(target))
+ for (IExtensionPoint xpt : xpts) {
+ if (xpt.equals(target)) {
return true;
+ }
+ }
return false;
}
};

Back to the top