Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Hammer2019-06-14 18:01:57 +0000
committerPaul Pazderski2019-06-15 15:17:08 +0000
commit1e85f9c9c33e8d3b31e6dbe2d1ce40182a041857 (patch)
tree7552c5a980252e5ed0a5e4c04bd4ff34d824a028 /examples
parent3a934d23cb1afac1bb9cc7302248ee2c3f126ed3 (diff)
downloadeclipse.platform.team-1e85f9c9c33e8d3b31e6dbe2d1ce40182a041857.tar.gz
eclipse.platform.team-1e85f9c9c33e8d3b31e6dbe2d1ce40182a041857.tar.xz
eclipse.platform.team-1e85f9c9c33e8d3b31e6dbe2d1ce40182a041857.zip
Use jdk 5 for-each loopI20190616-1800I20190615-1800
Replace simple uses of Iterator with a corresponding for-each loop. Also add missing braces on loops as necessary. Change-Id: I8cee98245fb49892d80949d1dcda89c9bf72f3e4 Signed-off-by: Carsten Hammer <carsten.hammer@t-online.de>
Diffstat (limited to 'examples')
-rw-r--r--examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/AbstractMatching.java23
-rw-r--r--examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/ChooseMatcherDropDownAction.java8
-rw-r--r--examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/OrderedMatching.java22
-rw-r--r--examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLComparePreferencePage.java8
-rw-r--r--examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLPlugin.java13
-rw-r--r--examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/ui/StatusUtil.java3
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/ConfigurationWizard.java3
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/OpenFileSystemRevisionAction.java13
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/localhistory/RevertAllOperation.java3
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/PessimisticDecorator.java4
10 files changed, 44 insertions, 56 deletions
diff --git a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/AbstractMatching.java b/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/AbstractMatching.java
index 032330665..41e19227c 100644
--- a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/AbstractMatching.java
+++ b/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/AbstractMatching.java
@@ -43,8 +43,9 @@ public abstract class AbstractMatching {
leaves.add(root);
} else {
Object[] children = root.getChildren();
- for (int i=0; i<children.length; i++)
- findLeaves((XMLNode) children[i], leaves);
+ for (Object child : children) {
+ findLeaves((XMLNode) child, leaves);
+ }
}
}
@@ -60,8 +61,9 @@ public abstract class AbstractMatching {
numbering.add(root);
Object[] children = root.getChildren();
if (children != null) {
- for (int i=0; i<children.length; i++)
- numberNodes((XMLNode) children[i], numbering);
+ for (Object child : children) {
+ numberNodes((XMLNode) child, numbering);
+ }
}
}
}
@@ -72,8 +74,9 @@ public abstract class AbstractMatching {
int count = 1;
if (isLeaf(root)) return count;
Object[] children = root.getChildren();
- for (int i=0; i<children.length; i++)
- count+=countNodes((XMLNode) children[i]);
+ for (Object child : children) {
+ count += countNodes((XMLNode) child);
+ }
return count;
}
@@ -182,8 +185,7 @@ public abstract class AbstractMatching {
int cur_pos_left= 0;
int cur_pos_right= 0;
- for (int i= 0; i < differences.length; i++) {
- RangeDifference rd= differences[i];
+ for (RangeDifference rd : differences) {
int equal_length= rd.leftStart();
//handle elements before current range which are unchanged
while (cur_pos_left < equal_length) {
@@ -197,7 +199,7 @@ public abstract class AbstractMatching {
cur_pos_left++;
cur_pos_right++;
}
- //now handle RangeDifference rd[i]
+ //now handle RangeDifference rd
int smaller_length, greater_length;
boolean leftGreater= rd.leftLength() > rd.rightLength();
if (leftGreater) {
@@ -207,7 +209,6 @@ public abstract class AbstractMatching {
smaller_length= rd.leftLength();
greater_length= rd.rightLength();
}
-
//handle elements elements in range
for (int j=0; j < smaller_length; j++) {
distance += dist((XMLNode) xc_elements[cur_pos_left], (XMLNode) yc_elements[cur_pos_right]);
@@ -225,7 +226,7 @@ public abstract class AbstractMatching {
} else {
for (int j=smaller_length; j < greater_length; j++) {
distance += countNodes((XMLNode) yc_elements[cur_pos_right]);
- DTMatching.add(new Match( null, (XMLNode)yc_elements[cur_pos_right]));
+ DTMatching.add(new Match( null, (XMLNode)yc_elements[cur_pos_right]));
cur_pos_right++;
}
}
diff --git a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/ChooseMatcherDropDownAction.java b/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/ChooseMatcherDropDownAction.java
index d297f9265..3441593c0 100644
--- a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/ChooseMatcherDropDownAction.java
+++ b/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/ChooseMatcherDropDownAction.java
@@ -65,8 +65,8 @@ class ChooseMatcherDropDownAction extends Action implements IMenuCreator {
}
Object[] internalIdMapsA= internalIdMapsAL.toArray();
Arrays.sort(internalIdMapsA);
- for (int i= 0; i < internalIdMapsA.length; i++) {
- addActionToMenu(menu, new SelectMatcherAction((String)internalIdMapsA[i], fViewer));
+ for (Object internalIdA : internalIdMapsA) {
+ addActionToMenu(menu, new SelectMatcherAction((String) internalIdA, fViewer));
}
new MenuItem(menu, SWT.SEPARATOR);
@@ -87,8 +87,8 @@ class ChooseMatcherDropDownAction extends Action implements IMenuCreator {
Object[] userIdMapsA= userIdMapsAL.toArray();
Arrays.sort(userIdMapsA);
- for (int i= 0; i < userIdMapsA.length; i++) {
- addActionToMenu(menu, new SelectMatcherAction((String)userIdMapsA[i], fViewer));
+ for (Object userIdA : userIdMapsA) {
+ addActionToMenu(menu, new SelectMatcherAction((String) userIdA, fViewer));
}
return menu;
diff --git a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/OrderedMatching.java b/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/OrderedMatching.java
index cb2ff4029..6f4086f3d 100644
--- a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/OrderedMatching.java
+++ b/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/OrderedMatching.java
@@ -38,23 +38,22 @@ public class OrderedMatching extends AbstractMatching {
ArrayList<XMLNode> yc_attrsAL= new ArrayList<>();
//find attributes and elements and put them in xc_elementsAL and xc_attrsAL, respectively
- for (int i= 0; i < xc.length; i++) {
- XMLNode x_i= (XMLNode) xc[i];
+ for (Object xc1 : xc) {
+ XMLNode x_i = (XMLNode) xc1;
if (x_i.getXMLType().equals(XMLStructureCreator.TYPE_ELEMENT)) {
xc_elementsAL.add(x_i);
} else if (
- x_i.getXMLType().equals(XMLStructureCreator.TYPE_ATTRIBUTE)) {
+ x_i.getXMLType().equals(XMLStructureCreator.TYPE_ATTRIBUTE)) {
xc_attrsAL.add(x_i);
}
}
-
- //do the same for yc
- for (int i= 0; i < yc.length; i++) {
- XMLNode y_i= (XMLNode) yc[i];
+ //do the same for yc
+ for (Object yc1 : yc) {
+ XMLNode y_i = (XMLNode) yc1;
if (y_i.getXMLType().equals(XMLStructureCreator.TYPE_ELEMENT)) {
yc_elementsAL.add(y_i);
} else if (
- y_i.getXMLType().equals(XMLStructureCreator.TYPE_ATTRIBUTE)) {
+ y_i.getXMLType().equals(XMLStructureCreator.TYPE_ATTRIBUTE)) {
yc_attrsAL.add(y_i);
}
}
@@ -188,12 +187,9 @@ public class OrderedMatching extends AbstractMatching {
ArrayList<XMLNode> yc_attrs,
ArrayList<Match> DTMatching) {
int distance= 0;
- x_for : for (
- Iterator<XMLNode> iter_xc= xc_attrs.iterator(); iter_xc.hasNext();) {
- XMLNode x_attr= iter_xc.next();
+ x_for : for (XMLNode x_attr : xc_attrs) {
String x_attr_name= x_attr.getName();
- for (Iterator<XMLNode> iter_yc= yc_attrs.iterator(); iter_yc.hasNext();) {
- XMLNode y_attr= iter_yc.next();
+ for (XMLNode y_attr : yc_attrs) {
if (y_attr.getName().equals(x_attr_name)) {
if (!y_attr.getValue().equals(x_attr.getValue()))
distance += 1;
diff --git a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLComparePreferencePage.java b/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLComparePreferencePage.java
index 33d63ae39..f4eb8115d 100644
--- a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLComparePreferencePage.java
+++ b/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLComparePreferencePage.java
@@ -441,13 +441,13 @@ public class XMLComparePreferencePage extends PreferencePage implements IWorkben
fOrderedElements.remove( IdMapName );
//All the corresponding ID Mappings must be removed as well
TableItem[] itemsMappings = fMappingsTable.getItems();
- for (int i=0; i<itemsMappings.length; i++) {
- itemsMappings[i].dispose();
+ for (TableItem itemsMapping : itemsMappings) {
+ itemsMapping.dispose();
}
//All the corresponding Ordered entries must be removed as well
TableItem[] itemsOrdered= fOrderedTable.getItems();
- for (int i= 0; i < itemsOrdered.length; i++) {
- itemsOrdered[i].dispose();
+ for (TableItem itemsOrd : itemsOrdered) {
+ itemsOrd.dispose();
}
//Remove extension
if (!itemsIdMap[0].getText(2).equals("")) { //$NON-NLS-1$
diff --git a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLPlugin.java b/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLPlugin.java
index d18c76dc9..84de2798f 100644
--- a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLPlugin.java
+++ b/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLPlugin.java
@@ -291,8 +291,7 @@ public final class XMLPlugin extends AbstractUIPlugin {
IConfigurationElement[] idmaps= registry.getConfigurationElementsFor(PLUGIN_ID, ID_MAPPING_EXTENSION_POINT);
fIdMapsInternal = new HashMap();
fOrderedElementsInternal= new HashMap();
- for (int i_idmap= 0; i_idmap < idmaps.length; i_idmap++) {
- final IConfigurationElement idmap= idmaps[i_idmap];
+ for (IConfigurationElement idmap : idmaps) {
//handle IDMAP_NAME_ATTRIBUTE
String idmap_name= idmap.getAttribute(IDMAP_NAME_ATTRIBUTE);
//ignores idmap if its name equals the reserved name for unordered matching or the the name for ordered matching
@@ -301,8 +300,7 @@ public final class XMLPlugin extends AbstractUIPlugin {
HashMap idmapHM = new HashMap();
fIdMapsInternal.put(idmap_name, idmapHM);
IConfigurationElement[] mappings = idmap.getChildren(MAPPING_ELEMENT_NAME);
- for (int i_mapping= 0; i_mapping < mappings.length; i_mapping++) {
- IConfigurationElement mapping = mappings[i_mapping];
+ for (IConfigurationElement mapping : mappings) {
//add SIGN_SEPARATOR at the end because not contained in signatures of plugin.xml
//also add prefix at beginning
String signature= mapping.getAttribute(MAPPING_SIGNATURE_ATTRIBUTE);
@@ -321,8 +319,7 @@ public final class XMLPlugin extends AbstractUIPlugin {
IConfigurationElement[] orderedEntries= idmap.getChildren(ORDERED_ELEMENT_NAME);
if (orderedEntries.length > 0) {
ArrayList orderedAL= new ArrayList();
- for (int i_ordered= 0; i_ordered < orderedEntries.length; i_ordered++) {
- IConfigurationElement ordered= orderedEntries[i_ordered];
+ for (IConfigurationElement ordered : orderedEntries) {
//add SIGN_SEPARATOR at the end because not contained in signatures of plugin.xml
//also add prefix at beginning
String signature= ordered.getAttribute(ORDERED_SIGNATURE_ATTRIBUTE);
@@ -383,8 +380,8 @@ public final class XMLPlugin extends AbstractUIPlugin {
shell= shell.getParent();
}
Shell shells[]= display.getShells();
- for (int i= 0; i < shells.length; i++) {
- Object data= shells[i].getData();
+ for (Shell s : shells) {
+ Object data = s.getData();
if (data instanceof IWorkbenchWindow) {
windowRef.window= (IWorkbenchWindow)data;
return;
diff --git a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/ui/StatusUtil.java b/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/ui/StatusUtil.java
index 38dfc0aa9..39cfdc0cc 100644
--- a/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/ui/StatusUtil.java
+++ b/examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/ui/StatusUtil.java
@@ -40,8 +40,7 @@ public class StatusUtil {
*/
public static IStatus getMostSevere(IStatus[] status) {
IStatus max= null;
- for (int i= 0; i < status.length; i++) {
- IStatus curr= status[i];
+ for (IStatus curr : status) {
if (curr.matches(IStatus.ERROR)) {
return curr;
}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/ConfigurationWizard.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/ConfigurationWizard.java
index bb0639185..73826aa8b 100644
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/ConfigurationWizard.java
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/ConfigurationWizard.java
@@ -80,8 +80,7 @@ public class ConfigurationWizard extends Wizard implements IConfigurationWizard,
FileSystemProvider provider = (FileSystemProvider) RepositoryProvider.getProvider(projects[0]);
provider.setTargetLocation(mainPage.getLocation());
} else {
- for (int i = 0; i < projects.length; i++) {
- IProject project = projects[i];
+ for (IProject project : projects) {
RepositoryProvider.map(project, FileSystemPlugin.PROVIDER_ID);
FileSystemProvider provider = (FileSystemProvider) RepositoryProvider.getProvider(project);
String path = new Path(mainPage.getLocation()).append(project.getName()).toOSString();
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/OpenFileSystemRevisionAction.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/OpenFileSystemRevisionAction.java
index 965c67188..b76fd02a8 100644
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/OpenFileSystemRevisionAction.java
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/OpenFileSystemRevisionAction.java
@@ -52,9 +52,7 @@ public class OpenFileSystemRevisionAction extends BaseSelectionListenerAction {
Object[] objArray = structSel.toArray();
- for (int i = 0; i < objArray.length; i++) {
- Object tempRevision = objArray[i];
-
+ for (Object tempRevision : objArray) {
final IFileRevision revision = (IFileRevision) tempRevision;
if (revision == null || !revision.exists()) {
MessageDialog.openError(page.getSite().getShell(), "Deleted Revision", "Can't open a deleted revision");
@@ -88,7 +86,6 @@ public class OpenFileSystemRevisionAction extends BaseSelectionListenerAction {
// ignore
}
}
-
}
}
@@ -133,8 +130,8 @@ public class OpenFileSystemRevisionAction extends BaseSelectionListenerAction {
if (objArray.length == 0)
return false;
- for (int i = 0; i < objArray.length; i++) {
- IFileRevision revision = (IFileRevision) objArray[i];
+ for (Object obj : objArray) {
+ IFileRevision revision = (IFileRevision) obj;
//check to see if any of the selected revisions are deleted revisions
if (revision != null && !revision.exists())
return false;
@@ -145,8 +142,8 @@ public class OpenFileSystemRevisionAction extends BaseSelectionListenerAction {
boolean editorAlreadyOpenOnContents(FileSystemRevisionEditorInput input) {
IEditorReference[] editorRefs = page.getSite().getPage().getEditorReferences();
- for (int i = 0; i < editorRefs.length; i++) {
- IEditorPart part = editorRefs[i].getEditor(false);
+ for (IEditorReference editorRef : editorRefs) {
+ IEditorPart part = editorRef.getEditor(false);
if (part != null && part.getEditorInput() instanceof FileSystemRevisionEditorInput) {
IFileRevision inputRevision = input.getAdapter(IFileRevision.class);
IFileRevision editorRevision = part.getEditorInput().getAdapter(IFileRevision.class);
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/localhistory/RevertAllOperation.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/localhistory/RevertAllOperation.java
index c1551e571..17a163aac 100644
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/localhistory/RevertAllOperation.java
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/localhistory/RevertAllOperation.java
@@ -40,8 +40,7 @@ public class RevertAllOperation extends SynchronizeModelOperation {
public void execute(IProgressMonitor pm) throws InvocationTargetException {
try {
pm.beginTask("Reverting from local history", 100 * infos.length); //$NON-NLS-1$
- for (int i = 0; i < infos.length; i++) {
- SyncInfo info = infos[i];
+ for (SyncInfo info : infos) {
LocalHistoryVariant state = (LocalHistoryVariant)info.getRemote();
IFile file = (IFile)info.getLocal();
if(file.exists()) {
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/PessimisticDecorator.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/PessimisticDecorator.java
index a5a66078c..463fe03bd 100644
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/PessimisticDecorator.java
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/PessimisticDecorator.java
@@ -89,8 +89,8 @@ public class PessimisticDecorator extends LabelProvider implements ILabelDecorat
private void postLabelEvents(final LabelProviderChangedEvent[] events) {
if (events != null && events.length > 0) {
Display.getDefault().asyncExec(() -> {
- for (int i= 0; i < events.length; i++) {
- fireLabelProviderChanged(events[i]);
+ for (LabelProviderChangedEvent event : events) {
+ fireLabelProviderChanged(event);
}
});
}

Back to the top