Use jdk 5 for-each loop
Replace simple uses of Iterator with a corresponding for-loop. Also add
missing braces on loops as necessary.
Change-Id: I154dddc591733c4c7b5714933522af71adebe657
Signed-off-by: Carsten Hammer <carsten.hammer@t-online.de>
diff --git a/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/launchConfigurations/ContributedClasspathEntriesEntry.java b/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/launchConfigurations/ContributedClasspathEntriesEntry.java
index 83268c8..dd31631 100644
--- a/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/launchConfigurations/ContributedClasspathEntriesEntry.java
+++ b/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/launchConfigurations/ContributedClasspathEntriesEntry.java
@@ -112,16 +112,16 @@
IAntClasspathEntry[] userEntries = prefs.getAdditionalClasspathEntries();
List<IRuntimeClasspathEntry> rtes = new ArrayList<>(antClasspathEntries.length + userEntries.length);
IAntClasspathEntry entry;
- for (int i = 0; i < antClasspathEntries.length; i++) {
- entry = antClasspathEntries[i];
+ for (IAntClasspathEntry antClasspathEntry : antClasspathEntries) {
+ entry = antClasspathEntry;
if (!separateVM || (separateVM && !entry.isEclipseRuntimeRequired())) {
rtes.add(JavaRuntime.newStringVariableClasspathEntry(entry.getLabel()));
}
}
boolean haveToolsEntry = false;
String path;
- for (int i = 0; i < userEntries.length; i++) {
- entry = userEntries[i];
+ for (IAntClasspathEntry userEntry : userEntries) {
+ entry = userEntry;
path = entry.getLabel();
IPath toolsPath = new Path(path);
if (toolsPath.lastSegment().equals("tools.jar")) { //$NON-NLS-1$
@@ -230,8 +230,7 @@
return name.endsWith(".jar"); //$NON-NLS-1$
}
});
- for (int j = 0; j < names.length; j++) {
- String jarName = names[j];
+ for (String jarName : names) {
fgSWTEntries.add(JavaRuntime.newArchiveRuntimeClasspathEntry(fragmentPath.append(jarName)));
}
}
diff --git a/ant/org.eclipse.ant.tests.ui/Ant Editor Tests/org/eclipse/ant/tests/ui/editor/CodeCompletionTest.java b/ant/org.eclipse.ant.tests.ui/Ant Editor Tests/org/eclipse/ant/tests/ui/editor/CodeCompletionTest.java
index 840cdc0..395511f 100644
--- a/ant/org.eclipse.ant.tests.ui/Ant Editor Tests/org/eclipse/ant/tests/ui/editor/CodeCompletionTest.java
+++ b/ant/org.eclipse.ant.tests.ui/Ant Editor Tests/org/eclipse/ant/tests/ui/editor/CodeCompletionTest.java
@@ -290,14 +290,14 @@
assertContains("pretest", proposals); //$NON-NLS-1$
assertContains("test2", proposals); //$NON-NLS-1$
- for (int i = 0; i < proposals.length; i++) {
- String displayString = proposals[i].getDisplayString();
+ for (ICompletionProposal proposal : proposals) {
+ String displayString = proposal.getDisplayString();
if (displayString.equals("main")) { //$NON-NLS-1$
- assertEquals(AntUIImages.getImage(IAntUIConstants.IMG_ANT_DEFAULT_TARGET), proposals[i].getImage());
+ assertEquals(AntUIImages.getImage(IAntUIConstants.IMG_ANT_DEFAULT_TARGET), proposal.getImage());
} else if (displayString.equals("pretest")) { //$NON-NLS-1$
- assertEquals(AntUIImages.getImage(IAntUIConstants.IMG_ANT_TARGET), proposals[i].getImage());
+ assertEquals(AntUIImages.getImage(IAntUIConstants.IMG_ANT_TARGET), proposal.getImage());
} else if (displayString.equals("test2")) { //$NON-NLS-1$
- assertEquals(AntUIImages.getImage(IAntUIConstants.IMG_ANT_TARGET_INTERNAL), proposals[i].getImage());
+ assertEquals(AntUIImages.getImage(IAntUIConstants.IMG_ANT_TARGET_INTERNAL), proposal.getImage());
} else {
fail("Unknown completion proposal detected: " + displayString); //$NON-NLS-1$
}
@@ -322,14 +322,14 @@
assertContains("task2", proposals); //$NON-NLS-1$
assertContains("task3", proposals); //$NON-NLS-1$
- for (int i = 0; i < proposals.length; i++) {
- String displayString = proposals[i].getDisplayString();
+ for (ICompletionProposal proposal : proposals) {
+ String displayString = proposal.getDisplayString();
if (displayString.equals("task3")) { //$NON-NLS-1$
- assertEquals(AntUIImages.getImage(IAntUIConstants.IMG_ANT_DEFAULT_TARGET), proposals[i].getImage());
+ assertEquals(AntUIImages.getImage(IAntUIConstants.IMG_ANT_DEFAULT_TARGET), proposal.getImage());
} else if (displayString.equals("task")) { //$NON-NLS-1$
- assertEquals(AntUIImages.getImage(IAntUIConstants.IMG_ANT_TARGET), proposals[i].getImage());
+ assertEquals(AntUIImages.getImage(IAntUIConstants.IMG_ANT_TARGET), proposal.getImage());
} else if (displayString.equals("task2")) { //$NON-NLS-1$
- assertEquals(AntUIImages.getImage(IAntUIConstants.IMG_ANT_TARGET_INTERNAL), proposals[i].getImage());
+ assertEquals(AntUIImages.getImage(IAntUIConstants.IMG_ANT_TARGET_INTERNAL), proposal.getImage());
} else {
fail("Unknown completion proposal detected: " + displayString); //$NON-NLS-1$
}
@@ -352,12 +352,12 @@
assertContains("task", proposals); //$NON-NLS-1$
assertContains("task3", proposals); //$NON-NLS-1$
- for (int i = 0; i < proposals.length; i++) {
- String displayString = proposals[i].getDisplayString();
+ for (ICompletionProposal proposal : proposals) {
+ String displayString = proposal.getDisplayString();
if (displayString.equals("task3")) { //$NON-NLS-1$
- assertEquals(AntUIImages.getImage(IAntUIConstants.IMG_ANT_DEFAULT_TARGET), proposals[i].getImage());
+ assertEquals(AntUIImages.getImage(IAntUIConstants.IMG_ANT_DEFAULT_TARGET), proposal.getImage());
} else if (displayString.equals("task")) { //$NON-NLS-1$
- assertEquals(AntUIImages.getImage(IAntUIConstants.IMG_ANT_TARGET), proposals[i].getImage());
+ assertEquals(AntUIImages.getImage(IAntUIConstants.IMG_ANT_TARGET), proposal.getImage());
} else {
fail("Unknown completion proposal detected: " + displayString); //$NON-NLS-1$
}
@@ -423,8 +423,7 @@
*/
private void assertContains(String displayString, ICompletionProposal[] proposalArray) {
boolean found = false;
- for (int i = 0; i < proposalArray.length; i++) {
- ICompletionProposal proposal = proposalArray[i];
+ for (ICompletionProposal proposal : proposalArray) {
String proposalDisplayString = proposal.getDisplayString();
if (displayString.equals(proposalDisplayString)) {
found = true;
@@ -439,8 +438,7 @@
*/
private void assertDoesNotContain(String displayString, ICompletionProposal[] proposalArray) {
boolean found = false;
- for (int i = 0; i < proposalArray.length; i++) {
- ICompletionProposal proposal = proposalArray[i];
+ for (ICompletionProposal proposal : proposalArray) {
String proposalDisplayString = proposal.getDisplayString();
if (displayString.equals(proposalDisplayString)) {
found = true;
diff --git a/ant/org.eclipse.ant.tests.ui/Ant Tests/org/eclipse/ant/tests/ui/AntViewTests.java b/ant/org.eclipse.ant.tests.ui/Ant Tests/org/eclipse/ant/tests/ui/AntViewTests.java
index c7afaa0..0429142 100644
--- a/ant/org.eclipse.ant.tests.ui/Ant Tests/org/eclipse/ant/tests/ui/AntViewTests.java
+++ b/ant/org.eclipse.ant.tests.ui/Ant Tests/org/eclipse/ant/tests/ui/AntViewTests.java
@@ -51,9 +51,9 @@
private AddBuildFilesAction getAddBuildFilesAction(IToolBarManager toolBarMgr) {
IContributionItem[] actions = toolBarMgr.getItems();
if (actions != null && actions.length > 0) {
- for (int i = 0; i < actions.length; i++) {
- if (actions[i] instanceof ActionContributionItem) {
- ActionContributionItem actionItem = (ActionContributionItem) actions[i];
+ for (IContributionItem action : actions) {
+ if (action instanceof ActionContributionItem) {
+ ActionContributionItem actionItem = (ActionContributionItem) action;
if (actionItem.getAction() instanceof AddBuildFilesAction) {
return (AddBuildFilesAction) actionItem.getAction();
}
diff --git a/ant/org.eclipse.ant.tests.ui/External Tools/org/eclipse/ant/tests/ui/externaltools/BuilderCoreUtilsTests.java b/ant/org.eclipse.ant.tests.ui/External Tools/org/eclipse/ant/tests/ui/externaltools/BuilderCoreUtilsTests.java
index b339019..230ef29 100644
--- a/ant/org.eclipse.ant.tests.ui/External Tools/org/eclipse/ant/tests/ui/externaltools/BuilderCoreUtilsTests.java
+++ b/ant/org.eclipse.ant.tests.ui/External Tools/org/eclipse/ant/tests/ui/externaltools/BuilderCoreUtilsTests.java
@@ -499,9 +499,9 @@
int[] array = BuilderCoreUtils.buildTypesToArray(kinds);
assertNotNull("The build kinds array cannot be null", array); //$NON-NLS-1$
boolean contains = true;
- for (int i = 0; i < array.length; i++) {
- contains &= (array[i] == IncrementalProjectBuilder.AUTO_BUILD) | (array[i] == IncrementalProjectBuilder.CLEAN_BUILD)
- | (array[i] == IncrementalProjectBuilder.FULL_BUILD) | (array[i] == IncrementalProjectBuilder.INCREMENTAL_BUILD);
+ for (int element : array) {
+ contains &= (element == IncrementalProjectBuilder.AUTO_BUILD) | (element == IncrementalProjectBuilder.CLEAN_BUILD)
+ | (element == IncrementalProjectBuilder.FULL_BUILD) | (element == IncrementalProjectBuilder.INCREMENTAL_BUILD);
if (!contains) {
break;
}
diff --git a/ant/org.eclipse.ant.tests.ui/test plugin/org/eclipse/ant/tests/ui/testplugin/ConsoleLineTracker.java b/ant/org.eclipse.ant.tests.ui/test plugin/org/eclipse/ant/tests/ui/testplugin/ConsoleLineTracker.java
index 4c0974a..78f2a06 100644
--- a/ant/org.eclipse.ant.tests.ui/test plugin/org/eclipse/ant/tests/ui/testplugin/ConsoleLineTracker.java
+++ b/ant/org.eclipse.ant.tests.ui/test plugin/org/eclipse/ant/tests/ui/testplugin/ConsoleLineTracker.java
@@ -79,8 +79,7 @@
public static List<String> getAllMessages() {
List<String> all = new ArrayList<>(lines.size());
- for (int i = 0; i < lines.size(); i++) {
- IRegion lineRegion = lines.get(i);
+ for (IRegion lineRegion : lines) {
try {
all.add(console.getDocument().get(lineRegion.getOffset(), lineRegion.getLength()));
}
diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/datatransfer/BuildFileCreator.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/datatransfer/BuildFileCreator.java
index 3fc876a..202d181 100644
--- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/datatransfer/BuildFileCreator.java
+++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/datatransfer/BuildFileCreator.java
@@ -148,8 +148,7 @@
// determine files to create/change
List<IFile> files = new ArrayList<>();
- for (Iterator<IJavaProject> iter = projects.iterator(); iter.hasNext();) {
- IJavaProject currentProject = iter.next();
+ for (IJavaProject currentProject : projects) {
IFile file = currentProject.getProject().getFile(BuildFileCreator.BUILD_XML);
files.add(file);
}
@@ -249,8 +248,7 @@
// <property name="x" value="y"/>
boolean first = true;
Node node = root.getFirstChild();
- for (Iterator<String> iterator = variable2valueMap.keySet().iterator(); iterator.hasNext();) {
- String key = iterator.next();
+ for (String key : variable2valueMap.keySet()) {
String value = variable2valueMap.get(key);
Element prop = doc.createElement("property"); //$NON-NLS-1$
prop.setAttribute(IAntCoreConstants.NAME, key);
@@ -302,10 +300,9 @@
if (files == null) {
return;
}
- for (int i = 0; i < files.length; i++) {
+ for (File file : files) {
// import file if it is an XML document with marker comment as first
// child
- File file = files[i];
Document docCandidate;
try {
docCandidate = ExportUtil.parseXmlFile(file);
@@ -364,8 +361,7 @@
element.setAttribute("id", pathid); //$NON-NLS-1$
visited.add(pathid);
variable2valueMap.putAll(classpath.variable2valueMap);
- for (Iterator<String> iter = ExportUtil.removeDuplicates(classpath.rawClassPathEntries).iterator(); iter.hasNext();) {
- String entry = iter.next();
+ for (String entry : ExportUtil.removeDuplicates(classpath.rawClassPathEntries)) {
if (EclipseClasspath.isProjectReference(entry)) {
Element pathElement = doc.createElement("path"); //$NON-NLS-1$
IJavaProject referencedProject = EclipseClasspath.resolveProjectReference(entry);
@@ -422,13 +418,12 @@
if (visited.add(entry)) {
Element userElement = doc.createElement("path"); //$NON-NLS-1$
userElement.setAttribute("id", name); //$NON-NLS-1$
- IClasspathEntry entries[] = container.getClasspathEntries();
- for (int i = 0; i < entries.length; i++) {
- String jarFile = entries[i].getPath().toString();
+ for (IClasspathEntry cpentry : container.getClasspathEntries()) {
+ String jarFile = cpentry.getPath().toString();
// use ECLIPSE_HOME variable for library jars
if (EclipseClasspath.isLibraryReference(entry)) {
IPath home = JavaCore.getClasspathVariable("ECLIPSE_HOME"); //$NON-NLS-1$
- if (home != null && home.isPrefixOf(entries[i].getPath())) {
+ if (home != null && home.isPrefixOf(cpentry.getPath())) {
variable2valueMap.put("ECLIPSE_HOME", home.toString()); //$NON-NLS-1$
jarFile = "${ECLIPSE_HOME}" + jarFile.substring(home.toString().length()); //$NON-NLS-1$
} else if (!new File(jarFile).exists() && jarFile.startsWith('/' + projectName)
@@ -482,8 +477,7 @@
* Add properties of sub-projects to internal properties map.
*/
public void addSubProperties(IJavaProject subproject, EclipseClasspath classpath) throws JavaModelException {
- for (Iterator<IJavaProject> iterator = ExportUtil.getClasspathProjectsRecursive(subproject).iterator(); iterator.hasNext();) {
- IJavaProject subProject = iterator.next();
+ for (IJavaProject subProject : ExportUtil.getClasspathProjectsRecursive(subproject)) {
String location = subProject.getProject().getName() + ".location"; //$NON-NLS-1$
// add subproject properties to variable2valueMap
String subProjectRoot = ExportUtil.getProjectRoot(subProject);
@@ -507,9 +501,7 @@
// </target>
Element element = doc.createElement("target"); //$NON-NLS-1$
element.setAttribute(IAntCoreConstants.NAME, "init"); //$NON-NLS-1$
- List<String> classDirsUnique = ExportUtil.removeDuplicates(classDirs);
- for (Iterator<String> iterator = classDirsUnique.iterator(); iterator.hasNext();) {
- String classDir = iterator.next();
+ for (String classDir : ExportUtil.removeDuplicates(classDirs)) {
if (!classDir.equals(".") && !EclipseClasspath.isReference(classDir)) { //$NON-NLS-1$
Element pathElement = doc.createElement("mkdir"); //$NON-NLS-1$
pathElement.setAttribute(IAntCoreConstants.DIR, classDir);
@@ -592,9 +584,7 @@
// </target>
Element element = doc.createElement("target"); //$NON-NLS-1$
element.setAttribute(IAntCoreConstants.NAME, "clean"); //$NON-NLS-1$
- List<String> classDirUnique = ExportUtil.removeDuplicates(classDirs);
- for (Iterator<String> iterator = classDirUnique.iterator(); iterator.hasNext();) {
- String classDir = iterator.next();
+ for (String classDir : ExportUtil.removeDuplicates(classDirs)) {
if (!classDir.equals(".") && //$NON-NLS-1$
!EclipseClasspath.isReference(classDir)) {
Element deleteElement = doc.createElement("delete"); //$NON-NLS-1$
@@ -630,9 +620,7 @@
Element element = doc.createElement("target"); //$NON-NLS-1$
element.setAttribute(IAntCoreConstants.NAME, "cleanall"); //$NON-NLS-1$
element.setAttribute("depends", "clean"); //$NON-NLS-1$ //$NON-NLS-2$
- List<IJavaProject> subProjects = ExportUtil.getClasspathProjectsRecursive(project);
- for (Iterator<IJavaProject> iterator = subProjects.iterator(); iterator.hasNext();) {
- IJavaProject subProject = iterator.next();
+ for (IJavaProject subProject : ExportUtil.getClasspathProjectsRecursive(project)) {
Element antElement = doc.createElement("ant"); //$NON-NLS-1$
antElement.setAttribute("antfile", BUILD_XML); //$NON-NLS-1$
antElement.setAttribute(IAntCoreConstants.DIR, "${" + subProject.getProject().getName() + ".location}"); //$NON-NLS-1$ //$NON-NLS-2$
@@ -667,9 +655,7 @@
// </target>
element = doc.createElement("target"); //$NON-NLS-1$
element.setAttribute(IAntCoreConstants.NAME, "build-subprojects"); //$NON-NLS-1$
- List<IJavaProject> subProjects = ExportUtil.getClasspathProjectsRecursive(project);
- for (Iterator<IJavaProject> iterator = subProjects.iterator(); iterator.hasNext();) {
- IJavaProject subProject = iterator.next();
+ for (IJavaProject subProject : ExportUtil.getClasspathProjectsRecursive(project)) {
Element antElement = doc.createElement("ant"); //$NON-NLS-1$
antElement.setAttribute("antfile", BUILD_XML); //$NON-NLS-1$
antElement.setAttribute(IAntCoreConstants.DIR, "${" + subProject.getProject().getName() + ".location}"); //$NON-NLS-1$ //$NON-NLS-2$
@@ -786,13 +772,10 @@
*/
private void createBuildRef() throws JavaModelException {
Set<IJavaProject> refProjects = new TreeSet<>(ExportUtil.getJavaProjectComparator());
- IJavaProject[] projects = project.getJavaModel().getJavaProjects();
- for (int i = 0; i < projects.length; i++) {
- List<IJavaProject> subProjects = ExportUtil.getClasspathProjects(projects[i]);
- for (Iterator<IJavaProject> iter = subProjects.iterator(); iter.hasNext();) {
- IJavaProject p = iter.next();
- if (projectName.equals(p.getProject().getName())) {
- refProjects.add(projects[i]);
+ for (IJavaProject javaProject : project.getJavaModel().getJavaProjects()) {
+ for (IJavaProject subProject : ExportUtil.getClasspathProjects(javaProject)) {
+ if (projectName.equals(subProject.getProject().getName())) {
+ refProjects.add(javaProject);
}
}
}
@@ -805,8 +788,7 @@
element.setAttribute(IAntCoreConstants.NAME, "build-refprojects"); //$NON-NLS-1$
element.setAttribute(IAntCoreConstants.DESCRIPTION, "Build all projects which " + //$NON-NLS-1$
"reference this project. Useful to propagate changes."); //$NON-NLS-1$
- for (Iterator<IJavaProject> iter = refProjects.iterator(); iter.hasNext();) {
- IJavaProject p = iter.next();
+ for (IJavaProject p : refProjects) {
String location = p.getProject().getName() + ".location"; //$NON-NLS-1$
String refProjectRoot = ExportUtil.getProjectRoot(p);
String relativePath = ExportUtil.getRelativePath(refProjectRoot, projectRoot);
@@ -908,8 +890,7 @@
// </bootclasspath>
Element bootclasspathElement = doc.createElement("bootclasspath"); //$NON-NLS-1$
boolean bootclasspathUsed = false;
- for (Iterator<String> iter = srcDirs.iterator(); iter.hasNext();) {
- String entry = iter.next();
+ for (String entry : srcDirs) {
if (EclipseClasspath.isUserSystemLibraryReference(entry)) {
Element pathElement = doc.createElement("path"); //$NON-NLS-1$
pathElement.setAttribute("refid", ExportUtil.removePrefixAndSuffix(entry, "${", "}")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
@@ -943,10 +924,8 @@
// <classpath refid="project.classpath"/>
// </java>
// </target>
- ILaunchConfiguration[] confs = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurations();
boolean junitUsed = false;
- for (int i = 0; i < confs.length; i++) {
- ILaunchConfiguration conf = confs[i];
+ for (ILaunchConfiguration conf : DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurations()) {
if (!projectName.equals(conf.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, IAntCoreConstants.EMPTY_STRING))) {
continue;
}
@@ -1123,8 +1102,7 @@
IType[] types = ExportUtil.findTestsInContainer(container);
Set<IType> sortedTypes = new TreeSet<>(ExportUtil.getITypeComparator());
sortedTypes.addAll(Arrays.asList(types));
- for (Iterator<IType> iter = sortedTypes.iterator(); iter.hasNext();) {
- IType type = iter.next();
+ for (IType type : sortedTypes) {
Element testElement = doc.createElement("test"); //$NON-NLS-1$
testElement.setAttribute(IAntCoreConstants.NAME, type.getFullyQualifiedName());
testElement.setAttribute("todir", "${junit.output.dir}"); //$NON-NLS-1$ //$NON-NLS-2$
@@ -1259,8 +1237,7 @@
* name of value attribute
*/
private static void addElements(Map<String, String> map, Document doc, Element element, String elementName, String keyAttributeName, String valueAttributeName) {
- for (Iterator<String> iter = map.keySet().iterator(); iter.hasNext();) {
- String key = iter.next();
+ for (String key : map.keySet()) {
String value = map.get(key);
Element itemElement = doc.createElement(elementName);
itemElement.setAttribute(keyAttributeName, key);
diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/ClasspathModel.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/ClasspathModel.java
index d9be2e0..8567cc2 100644
--- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/ClasspathModel.java
+++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/ClasspathModel.java
@@ -172,8 +172,7 @@
public void removeAll(Object[] entries) {
- for (int i = 0; i < entries.length; i++) {
- Object object = entries[i];
+ for (Object object : entries) {
if (object instanceof ClasspathEntry) {
IClasspathEntry entryParent = ((ClasspathEntry) object).getParent();
if (entryParent instanceof GlobalClasspathEntries) {
@@ -193,8 +192,8 @@
fAntHomeEntry = createGlobalEntry(entries, name, false, true, ANT_HOME);
} else {
fAntHomeEntry.removeAll();
- for (int i = 0; i < entries.length; i++) {
- fAntHomeEntry.addEntry(new ClasspathEntry(entries[i], fAntHomeEntry));
+ for (IAntClasspathEntry entry : entries) {
+ fAntHomeEntry.addEntry(new ClasspathEntry(entry, fAntHomeEntry));
}
}
}
@@ -203,8 +202,8 @@
GlobalClasspathEntries global = new GlobalClasspathEntries(name, this, canBeRemoved, type);
- for (int i = 0; i < entries.length; i++) {
- global.addEntry(new ClasspathEntry(entries[i], global));
+ for (IAntClasspathEntry entry : entries) {
+ global.addEntry(new ClasspathEntry(entry, global));
}
if (addEntry) {
@@ -219,8 +218,8 @@
fUserGlobalEntry = createGlobalEntry(entries, name, true, true, GLOBAL_USER);
} else {
fUserGlobalEntry.removeAll();
- for (int i = 0; i < entries.length; i++) {
- fUserGlobalEntry.addEntry(new ClasspathEntry(entries[i], fUserGlobalEntry));
+ for (IAntClasspathEntry entry : entries) {
+ fUserGlobalEntry.addEntry(new ClasspathEntry(entry, fUserGlobalEntry));
}
}
}
@@ -231,8 +230,8 @@
fContributedGlobalEntry = createGlobalEntry(entries, name, false, true, CONTRIBUTED);
} else {
fContributedGlobalEntry.removeAll();
- for (int i = 0; i < entries.length; i++) {
- fContributedGlobalEntry.addEntry(new ClasspathEntry(entries[i], fContributedGlobalEntry));
+ for (IAntClasspathEntry entry : entries) {
+ fContributedGlobalEntry.addEntry(new ClasspathEntry(entry, fContributedGlobalEntry));
}
}
}
diff --git a/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/Configuration.java b/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/Configuration.java
index b49b997..f3d972f 100644
--- a/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/Configuration.java
+++ b/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/Configuration.java
@@ -56,9 +56,8 @@
public void setLinkedConfig(Configuration linkedConfig) {
this.linkedConfig = linkedConfig;
// make all the sites read-only
- SiteEntry[] linkedSites = linkedConfig.getSites();
- for (int i=0; i<linkedSites.length; i++)
- linkedSites[i].setUpdateable(false);
+ for (SiteEntry linkedSite : linkedConfig.getSites())
+ linkedSite.setUpdateable(false);
}
public Configuration getLinkedConfig() {
@@ -161,11 +160,10 @@
}
// collect site entries
- SiteEntry[] list = sites.values().toArray(new SiteEntry[0]);
- for (int i = 0; i < list.length; i++) {
- if (linkedConfig != null && linkedConfig.getSiteEntry(list[i].getURL().toExternalForm()) != null)
+ for (SiteEntry element : sites.values()) {
+ if (linkedConfig != null && linkedConfig.getSiteEntry(element.getURL().toExternalForm()) != null)
continue;
- Element siteElement = list[i].toXML(doc);
+ Element siteElement = element.toXML(doc);
configElement.appendChild(siteElement);
}
@@ -193,9 +191,8 @@
}
public boolean unconfigureFeatureEntry(IPlatformConfiguration.IFeatureEntry feature) {
- SiteEntry[] sites = getSites();
- for (int i=0; i<sites.length; i++)
- if (sites[i].unconfigureFeatureEntry(feature))
+ for (SiteEntry site : getSites())
+ if (site.unconfigureFeatureEntry(feature))
return true;
return false;
}
diff --git a/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/ConfigurationActivator.java b/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/ConfigurationActivator.java
index c4f63c3..c770b68 100644
--- a/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/ConfigurationActivator.java
+++ b/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/ConfigurationActivator.java
@@ -27,6 +27,7 @@
import org.eclipse.osgi.service.debug.DebugOptions;
import org.eclipse.osgi.util.NLS;
import org.eclipse.update.configurator.IPlatformConfiguration;
+import org.eclipse.update.configurator.IPlatformConfiguration.IFeatureEntry;
import org.eclipse.update.configurator.IPlatformConfigurationFactory;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
@@ -98,8 +99,8 @@
//don't register the service if this bundle has already registered it declaratively
ServiceReference<?>[] refs = getBundleContext().getServiceReferences(serviceName, null);
if (refs != null) {
- for (int i = 0; i < refs.length; i++)
- if (PI_CONFIGURATOR.equals(refs[i].getBundle().getSymbolicName()))
+ for (ServiceReference<?> ref : refs)
+ if (PI_CONFIGURATOR.equals(ref.getBundle().getSymbolicName()))
return;
}
} catch (InvalidSyntaxException e) {
@@ -220,9 +221,9 @@
IPlatformConfiguration.IFeatureEntry[] features = configuration.getConfiguredFeatureEntries();
ArrayList<IBundleGroup> bundleGroups = new ArrayList<>(features.length);
- for (int i = 0; i < features.length; i++) {
- if (features[i] instanceof FeatureEntry && ((FeatureEntry) features[i]).hasBranding())
- bundleGroups.add((IBundleGroup) features[i]);
+ for (IFeatureEntry feature : features) {
+ if (feature instanceof FeatureEntry && ((FeatureEntry) feature).hasBranding())
+ bundleGroups.add((IBundleGroup) feature);
}
return bundleGroups.toArray(new IBundleGroup[bundleGroups.size()]);
}
diff --git a/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/ConfigurationParser.java b/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/ConfigurationParser.java
index f59e563..5b3f8a1 100644
--- a/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/ConfigurationParser.java
+++ b/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/ConfigurationParser.java
@@ -385,9 +385,8 @@
// This is a bit of a hack.
// When no features were added to the site, but the site is initialized from platform.xml
// we need to set the feature set to empty, so we don't try to detect them.
- SiteEntry[] sites = config.getSites();
- for (int i=0; i<sites.length; i++)
- sites[i].initialized();
+ for (SiteEntry site : config.getSites())
+ site.initialized();
return;
}
} catch (Exception e) {