diff options
author | Lars Grefer <eclipse@larsgrefer.de> | 2020-08-08 03:06:37 +0200 |
---|---|---|
committer | Lars Grefer <eclipse@larsgrefer.de> | 2020-08-08 03:06:37 +0200 |
commit | 72194b7982ddfa8e9864d0a9934905bb76b90f33 (patch) | |
tree | ebed806c358c1a3960c5d6be4c13b26ca41809df /ajde | |
parent | c3289ab86bfb2c97cf34147239b3dde46de92a7c (diff) | |
download | aspectj-72194b7982ddfa8e9864d0a9934905bb76b90f33.tar.gz aspectj-72194b7982ddfa8e9864d0a9934905bb76b90f33.zip |
'for' loop replaceable with enhanced 'for' loop
Reports for loops which iterate over collections or arrays, and can be replaced with an enhanced for loop (i.e. the foreach iteration syntax).
Signed-off-by: Lars Grefer <eclipse@larsgrefer.de>
Diffstat (limited to 'ajde')
23 files changed, 106 insertions, 114 deletions
diff --git a/ajde/src/main/java/org/aspectj/ajde/Ajde.java b/ajde/src/main/java/org/aspectj/ajde/Ajde.java index 2e25e50fc..b458eb9da 100644 --- a/ajde/src/main/java/org/aspectj/ajde/Ajde.java +++ b/ajde/src/main/java/org/aspectj/ajde/Ajde.java @@ -262,8 +262,8 @@ public class Ajde { } else { StringBuffer sb = new StringBuffer(); List outputDirs = compilerConfig.getOutputLocationManager().getAllOutputLocations(); - for (Iterator iterator = outputDirs.iterator(); iterator.hasNext();) { - File dir = (File) iterator.next(); + for (Object outputDir : outputDirs) { + File dir = (File) outputDir; sb.append(dir.getAbsolutePath() + File.pathSeparator); } classpath = LangUtil.makeClasspath(null, compilerConfig.getClasspath(), sb.toString(), compilerConfig.getOutJar()); diff --git a/ajde/src/main/java/org/aspectj/ajde/internal/LstBuildConfigFileUpdater.java b/ajde/src/main/java/org/aspectj/ajde/internal/LstBuildConfigFileUpdater.java index ac6264436..f3e2154cd 100644 --- a/ajde/src/main/java/org/aspectj/ajde/internal/LstBuildConfigFileUpdater.java +++ b/ajde/src/main/java/org/aspectj/ajde/internal/LstBuildConfigFileUpdater.java @@ -56,20 +56,20 @@ class LstBuildConfigFileUpdater { * Adds an entry to multiple build configuration files. */ public void updateBuildConfigFiles(List buildConfigFiles, List<String> filesToUpdate, boolean addToConfiguration) { - for (int i = 0; i < buildConfigFiles.size(); i++) { - List<String> fileContents = readConfigFile((String) buildConfigFiles.get(i)); + for (Object buildConfigFile : buildConfigFiles) { + List<String> fileContents = readConfigFile((String) buildConfigFile); if (addToConfiguration) { - for (int j = 0; j < filesToUpdate.size(); j++) { - fileContents.add(filesToUpdate.get(j)); + for (String s : filesToUpdate) { + fileContents.add(s); } } else { - for (int k = 0; k < filesToUpdate.size(); k++) { - if (fileContents.contains(filesToUpdate.get(k))) { - fileContents.remove(filesToUpdate.get(k)); + for (String s : filesToUpdate) { + if (fileContents.contains(s)) { + fileContents.remove(s); } } } - writeConfigFile((String) buildConfigFiles.get(i), fileContents); + writeConfigFile((String) buildConfigFile, fileContents); } } @@ -122,16 +122,14 @@ class LstBuildConfigFileUpdater { String fileContentsString = ""; // List filesToWrite = null; Set<String> includedFiles = new HashSet<>(); - for (Iterator<BuildConfigNode> it = importedNodes.iterator(); it.hasNext();) { - BuildConfigNode node = it.next(); + for (BuildConfigNode node : importedNodes) { fileContentsString += '@' + node.getResourcePath() + "\n"; String parentPath = new File(filePath).getParent(); String importedFilePath = parentPath + File.separator + node.getResourcePath(); includedFiles.addAll(getIncludedFiles(importedFilePath, parentPath)); } - for (Iterator<BuildConfigNode> it = files.iterator(); it.hasNext();) { - BuildConfigNode node = it.next(); + for (BuildConfigNode node : files) { if (node.getName().endsWith(".lst") && !node.getResourcePath().startsWith("..")) { fileContentsString += '@'; fileContentsString += node.getResourcePath() + "\n"; @@ -150,8 +148,8 @@ class LstBuildConfigFileUpdater { configParser.parseConfigFile(new File(path)); List<File> files = configParser.getFiles(); List<String> relativeFiles = new ArrayList<String>(); - for (Iterator<File> it = files.iterator(); it.hasNext();) { - relativeFiles.add(relativizePath(it.next().getPath(), rootPath)); + for (File file : files) { + relativeFiles.add(relativizePath(file.getPath(), rootPath)); } return relativeFiles; } catch (ConfigParser.ParseException pe) { diff --git a/ajde/src/main/java/org/aspectj/ajde/internal/LstBuildConfigManager.java b/ajde/src/main/java/org/aspectj/ajde/internal/LstBuildConfigManager.java index 6bd0c23da..feda7df0c 100644 --- a/ajde/src/main/java/org/aspectj/ajde/internal/LstBuildConfigManager.java +++ b/ajde/src/main/java/org/aspectj/ajde/internal/LstBuildConfigManager.java @@ -173,8 +173,8 @@ public class LstBuildConfigManager implements BuildConfigManager { } node.addChild(dir); // boolean foundMatch = false; - for (Iterator it = importedFiles.iterator(); it.hasNext();) { - File importedFile = (File) it.next(); + for (Object file : importedFiles) { + File importedFile = (File) file; if (importedFile.getParentFile().getAbsolutePath().equals(dir2.getAbsolutePath())) { // foundMatch = true; BuildConfigNode importedFileNode = new BuildConfigNode(importedFile.getName(), BuildConfigNode.Kind.FILE_LST, @@ -215,8 +215,8 @@ public class LstBuildConfigManager implements BuildConfigManager { } private void addFilesToDirTree(BuildConfigModel model, List configFiles, List badEntries) { - for (Iterator it = configFiles.iterator(); it.hasNext();) { - String path = (String) it.next(); + for (Object configFile : configFiles) { + String path = (String) configFile; if (path.startsWith("..")) { File file = new File(path); BuildConfigNode node = new BuildConfigNode(file.getName(), BuildConfigNode.Kind.FILE_JAVA, path); diff --git a/ajde/src/main/java/org/aspectj/ajde/ui/StructureSearchManager.java b/ajde/src/main/java/org/aspectj/ajde/ui/StructureSearchManager.java index b6631b3a8..d9e9a0f52 100644 --- a/ajde/src/main/java/org/aspectj/ajde/ui/StructureSearchManager.java +++ b/ajde/src/main/java/org/aspectj/ajde/ui/StructureSearchManager.java @@ -51,8 +51,7 @@ public class StructureSearchManager { } } if (node != null && node.getChildren() != null) { - for (Iterator<IProgramElement> it = node.getChildren().iterator(); it.hasNext();) { - IProgramElement nextNode = it.next(); + for (IProgramElement nextNode : node.getChildren()) { if (nextNode != null) { findMatchesHelper(nextNode, pattern, kind, matches); } diff --git a/ajde/src/main/java/org/aspectj/ajde/ui/StructureView.java b/ajde/src/main/java/org/aspectj/ajde/ui/StructureView.java index edbae4698..7d6e4838b 100644 --- a/ajde/src/main/java/org/aspectj/ajde/ui/StructureView.java +++ b/ajde/src/main/java/org/aspectj/ajde/ui/StructureView.java @@ -83,8 +83,8 @@ public abstract class StructureView { } if (node != null && node.getChildren() != null) { - for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) { - IStructureViewNode foundNode = findCorrespondingViewNodeHelper((IStructureViewNode)it.next(), pNode); + for (Object o : node.getChildren()) { + IStructureViewNode foundNode = findCorrespondingViewNodeHelper((IStructureViewNode) o, pNode); if (foundNode != null) return foundNode; } } diff --git a/ajde/src/main/java/org/aspectj/ajde/ui/StructureViewManager.java b/ajde/src/main/java/org/aspectj/ajde/ui/StructureViewManager.java index eb8fdc033..9b23439e4 100644 --- a/ajde/src/main/java/org/aspectj/ajde/ui/StructureViewManager.java +++ b/ajde/src/main/java/org/aspectj/ajde/ui/StructureViewManager.java @@ -46,8 +46,8 @@ public class StructureViewManager { public void elementsUpdated(IHierarchy model) { // updating structure views: - for (Iterator it = structureViews.iterator(); it.hasNext();) { - treeViewBuilder.buildView((StructureView) it.next(), (AspectJElementHierarchy) model); + for (Object structureView : structureViews) { + treeViewBuilder.buildView((StructureView) structureView, (AspectJElementHierarchy) model); } } }; @@ -119,8 +119,8 @@ public class StructureViewManager { } } - for (Iterator it = structureViews.iterator(); it.hasNext();) { - StructureView view = (StructureView) it.next(); + for (Object structureView : structureViews) { + StructureView view = (StructureView) structureView; if (!(view instanceof GlobalStructureView) || !recordHistory || defaultFileView == null) { if (node.getKind().equals(IProgramElement.Kind.CODE)) { IProgramElement parentNode = node.getParent(); diff --git a/ajde/src/main/java/org/aspectj/ajde/ui/StructureViewNodeFactory.java b/ajde/src/main/java/org/aspectj/ajde/ui/StructureViewNodeFactory.java index cb82a65db..43513c14b 100644 --- a/ajde/src/main/java/org/aspectj/ajde/ui/StructureViewNodeFactory.java +++ b/ajde/src/main/java/org/aspectj/ajde/ui/StructureViewNodeFactory.java @@ -49,14 +49,13 @@ public abstract class StructureViewNodeFactory { IRelationshipMap relMap = (manager == null ? null : manager.getRelationshipMap()); List relationships = (relMap == null ? null : relMap.get(nodeHandle)); if (relationships != null) { - for (Iterator it = relationships.iterator(); it.hasNext();) { - IRelationship rel = (IRelationship) it.next(); + for (Object relationship : relationships) { + IRelationship rel = (IRelationship) relationship; if (rel != null && rel.getTargets().size() > 0) { IStructureViewNode relNode = createRelationship(rel, iconRegistry.getIcon(rel.getKind())); if (relNode != null) { svNode.add(relNode, 0); - for (Iterator it2 = rel.getTargets().iterator(); it2.hasNext();) { - String handle = (String) it2.next(); + for (String handle : rel.getTargets()) { IProgramElement link = Ajde.getDefault().getModel().getHierarchy().findElementForHandle(handle); if (link != null) { IStructureViewNode linkNode = createLink(link, iconRegistry.getStructureIcon(link.getKind(), diff --git a/ajde/src/main/java/org/aspectj/ajde/ui/internal/TreeStructureViewBuilder.java b/ajde/src/main/java/org/aspectj/ajde/ui/internal/TreeStructureViewBuilder.java index 728ed9069..23f999ac8 100644 --- a/ajde/src/main/java/org/aspectj/ajde/ui/internal/TreeStructureViewBuilder.java +++ b/ajde/src/main/java/org/aspectj/ajde/ui/internal/TreeStructureViewBuilder.java @@ -197,8 +197,8 @@ public class TreeStructureViewBuilder { private void sortView(IStructureViewNode node, Comparator<IStructureViewNode> comparator) { if (node == null || node.getChildren() == null) return; Collections.sort(node.getChildren(), comparator); - for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) { - IStructureViewNode nextNode = (IStructureViewNode)it.next(); + for (Object o : node.getChildren()) { + IStructureViewNode nextNode = (IStructureViewNode) o; if (nextNode != null) sortView(nextNode, comparator); } } diff --git a/ajde/src/main/java/org/aspectj/ajde/ui/internal/UserPreferencesStore.java b/ajde/src/main/java/org/aspectj/ajde/ui/internal/UserPreferencesStore.java index 572506aed..611af0b4e 100644 --- a/ajde/src/main/java/org/aspectj/ajde/ui/internal/UserPreferencesStore.java +++ b/ajde/src/main/java/org/aspectj/ajde/ui/internal/UserPreferencesStore.java @@ -76,8 +76,8 @@ public class UserPreferencesStore implements UserPreferencesAdapter { @Override public void setProjectMultivalPreference(String name, List values) { String valuesString = ""; - for (Iterator it = values.iterator(); it.hasNext(); ) { - valuesString += (String)it.next() + ';'; + for (Object value : values) { + valuesString += (String) value + ';'; } properties.setProperty(name, valuesString); saveProperties(); diff --git a/ajde/src/main/java/org/aspectj/ajde/ui/javaoptions/JavaCompilerWarningsOptionsPanel.java b/ajde/src/main/java/org/aspectj/ajde/ui/javaoptions/JavaCompilerWarningsOptionsPanel.java index 09d76afc8..51248d6c4 100644 --- a/ajde/src/main/java/org/aspectj/ajde/ui/javaoptions/JavaCompilerWarningsOptionsPanel.java +++ b/ajde/src/main/java/org/aspectj/ajde/ui/javaoptions/JavaCompilerWarningsOptionsPanel.java @@ -67,10 +67,10 @@ public class JavaCompilerWarningsOptionsPanel extends OptionsPanel { public void saveOptions() throws IOException { Set s = warningComboBoxes.entrySet(); - for (Iterator iterator = s.iterator(); iterator.hasNext();) { - Map.Entry entry = (Entry) iterator.next(); + for (Object o : s) { + Entry entry = (Entry) o; String javaOption = (String) entry.getKey(); - JComboBox combo = (JComboBox)entry.getValue(); + JComboBox combo = (JComboBox) entry.getValue(); String value = (String) combo.getSelectedItem(); javaBuildOptions.setOption(javaOption, value); } diff --git a/ajde/src/main/java/org/aspectj/ajde/ui/swing/BrowserStructureViewToolPanel.java b/ajde/src/main/java/org/aspectj/ajde/ui/swing/BrowserStructureViewToolPanel.java index 6988536da..6431eb851 100644 --- a/ajde/src/main/java/org/aspectj/ajde/ui/swing/BrowserStructureViewToolPanel.java +++ b/ajde/src/main/java/org/aspectj/ajde/ui/swing/BrowserStructureViewToolPanel.java @@ -72,8 +72,8 @@ public class BrowserStructureViewToolPanel extends JPanel { view_comboBox = new JComboBox(); view_comboBox.setFont(AjdeWidgetStyles.DEFAULT_LABEL_FONT); - for (Iterator it = structureViews.iterator(); it.hasNext(); ) { - view_comboBox.addItem(it.next()); + for (Object structureView : structureViews) { + view_comboBox.addItem(structureView); } try { @@ -120,26 +120,26 @@ public class BrowserStructureViewToolPanel extends JPanel { private JPopupMenu createFilterMenu() { JPopupMenu filterMenu = new JPopupMenu(); IProgramElement.Accessibility[] accessibility = IProgramElement.Accessibility.ALL; - for (int i = 0; i < accessibility.length; i++) { - CheckBoxSelectionMenuButton menuItem = new CheckBoxSelectionMenuButton(accessibility[i]); - menuItem.setIcon(Ajde.getDefault().getIconRegistry().getAccessibilitySwingIcon(accessibility[i])); + for (IProgramElement.Accessibility value : accessibility) { + CheckBoxSelectionMenuButton menuItem = new CheckBoxSelectionMenuButton(value); + menuItem.setIcon(Ajde.getDefault().getIconRegistry().getAccessibilitySwingIcon(value)); filterMenu.add(menuItem); } filterMenu.add(new JSeparator()); IProgramElement.Kind[] kinds = IProgramElement.Kind.ALL; - for (int i = 0; i < kinds.length; i++) { - if (kinds[i].isMember()) { - CheckBoxSelectionMenuButton menuItem = new CheckBoxSelectionMenuButton(kinds[i]); - menuItem.setIcon((Icon)Ajde.getDefault().getIconRegistry().getIcon(kinds[i]).getIconResource()); + for (IProgramElement.Kind kind : kinds) { + if (kind.isMember()) { + CheckBoxSelectionMenuButton menuItem = new CheckBoxSelectionMenuButton(kind); + menuItem.setIcon((Icon) Ajde.getDefault().getIconRegistry().getIcon(kind).getIconResource()); filterMenu.add(menuItem); } } filterMenu.add(new JSeparator()); IProgramElement.Modifiers[] modifiers = IProgramElement.Modifiers.ALL; - for (int i = 0; i < modifiers.length; i++) { - CheckBoxSelectionMenuButton menuItem = new CheckBoxSelectionMenuButton(modifiers[i]); + for (IProgramElement.Modifiers modifier : modifiers) { + CheckBoxSelectionMenuButton menuItem = new CheckBoxSelectionMenuButton(modifier); filterMenu.add(menuItem); } return filterMenu; @@ -149,10 +149,10 @@ public class BrowserStructureViewToolPanel extends JPanel { JPopupMenu relationsMenu = new JPopupMenu(); java.util.List relations = Ajde.getDefault().getStructureViewManager().getAvailableRelations(); - for (Iterator it = relations.iterator(); it.hasNext(); ) { - IRelationship.Kind relation = (IRelationship.Kind)it.next(); + for (Object o : relations) { + IRelationship.Kind relation = (IRelationship.Kind) o; CheckBoxSelectionMenuButton menuItem = new CheckBoxSelectionMenuButton(relation); - menuItem.setIcon((Icon)Ajde.getDefault().getIconRegistry().getIcon(relation).getIconResource()); + menuItem.setIcon((Icon) Ajde.getDefault().getIconRegistry().getIcon(relation).getIconResource()); relationsMenu.add(menuItem); } @@ -164,10 +164,10 @@ public class BrowserStructureViewToolPanel extends JPanel { StructureViewProperties.Granularity[] granularity = StructureViewProperties.Granularity.ALL; ButtonGroup group = new ButtonGroup(); - for (int i = 0; i < granularity.length; i++) { - RadioSelectionMenuButton menuItem = new RadioSelectionMenuButton(granularity[i], group); + for (StructureViewProperties.Granularity value : granularity) { + RadioSelectionMenuButton menuItem = new RadioSelectionMenuButton(value, group); orderMenu.add(menuItem); - if (granularity[i].equals(StructureViewProperties.Granularity.MEMBER)) { + if (value.equals(StructureViewProperties.Granularity.MEMBER)) { menuItem.setSelected(true); } } diff --git a/ajde/src/main/java/org/aspectj/ajde/ui/swing/BrowserView.java b/ajde/src/main/java/org/aspectj/ajde/ui/swing/BrowserView.java index d41827a41..e9c1196e2 100644 --- a/ajde/src/main/java/org/aspectj/ajde/ui/swing/BrowserView.java +++ b/ajde/src/main/java/org/aspectj/ajde/ui/swing/BrowserView.java @@ -121,9 +121,9 @@ class BrowserView extends JPanel { public void updateConfigs(java.util.List configsList) { configs_comboBox.removeAllItems(); - for (Iterator it = configsList.iterator(); it.hasNext(); ) { - configs_comboBox.addItem(it.next()); - } + for (Object o : configsList) { + configs_comboBox.addItem(o); + } } public void setSelectedConfig(String config) { diff --git a/ajde/src/main/java/org/aspectj/ajde/ui/swing/BrowserViewPanel.java b/ajde/src/main/java/org/aspectj/ajde/ui/swing/BrowserViewPanel.java index 0b15049b6..a32c53c52 100644 --- a/ajde/src/main/java/org/aspectj/ajde/ui/swing/BrowserViewPanel.java +++ b/ajde/src/main/java/org/aspectj/ajde/ui/swing/BrowserViewPanel.java @@ -67,12 +67,12 @@ public class BrowserViewPanel extends JPanel implements StructureViewRenderer { public BrowserViewPanel(IconRegistry icons, java.util.List views, StructureViewProperties.Hierarchy visibleViewHierarchy) { try { view_comboBox = new JComboBox(views.toArray()); - for (Iterator it = views.iterator(); it.hasNext(); ) { - StructureViewProperties.Hierarchy hierarchy = (StructureViewProperties.Hierarchy)it.next(); - if (hierarchy == visibleViewHierarchy) { - view_comboBox.setSelectedItem(hierarchy); - } - } + for (Object view : views) { + StructureViewProperties.Hierarchy hierarchy = (StructureViewProperties.Hierarchy) view; + if (hierarchy == visibleViewHierarchy) { + view_comboBox.setSelectedItem(hierarchy); + } + } //GlobalViewProperties visibleView = (GlobalViewProperties)viewProperties.get(visibleViewHierarchy.toString()); treeManager = new StructureTreeManager();//, visibleView); jbInit(); diff --git a/ajde/src/main/java/org/aspectj/ajde/ui/swing/BuildConfigPopupMenu.java b/ajde/src/main/java/org/aspectj/ajde/ui/swing/BuildConfigPopupMenu.java index 7ca7a35fd..0a59ab71a 100644 --- a/ajde/src/main/java/org/aspectj/ajde/ui/swing/BuildConfigPopupMenu.java +++ b/ajde/src/main/java/org/aspectj/ajde/ui/swing/BuildConfigPopupMenu.java @@ -39,23 +39,23 @@ public class BuildConfigPopupMenu extends JPopupMenu { public BuildConfigPopupMenu(final AbstractAction action) { List configFiles = Ajde.getDefault().getBuildConfigManager().getAllBuildConfigFiles(); - for (Iterator it = configFiles.iterator(); it.hasNext(); ) { - final String buildConfig = (String)it.next(); - JMenuItem buildItem = new JMenuItem(buildConfig); - buildItem.setFont(AjdeWidgetStyles.DEFAULT_LABEL_FONT); - buildItem.addActionListener( - new ActionListener() { - public void actionPerformed(ActionEvent e) { - Ajde.getDefault().getBuildConfigManager().setActiveConfigFile(buildConfig); - // A separate thread is required here because the buildProgresssMonitor - // that monitors the build needs to be in a different thread - // to that which is doing the build (swing threading issues) - Ajde.getDefault().runBuildInDifferentThread(buildConfig, true); - action.actionPerformed(e); - } - }); - buildItem.setIcon((Icon)Ajde.getDefault().getIconRegistry().getIcon(IProgramElement.Kind.FILE_LST).getIconResource()); - this.add(buildItem); + for (Object configFile : configFiles) { + final String buildConfig = (String) configFile; + JMenuItem buildItem = new JMenuItem(buildConfig); + buildItem.setFont(AjdeWidgetStyles.DEFAULT_LABEL_FONT); + buildItem.addActionListener( + new ActionListener() { + public void actionPerformed(ActionEvent e) { + Ajde.getDefault().getBuildConfigManager().setActiveConfigFile(buildConfig); + // A separate thread is required here because the buildProgresssMonitor + // that monitors the build needs to be in a different thread + // to that which is doing the build (swing threading issues) + Ajde.getDefault().runBuildInDifferentThread(buildConfig, true); + action.actionPerformed(e); + } + }); + buildItem.setIcon((Icon) Ajde.getDefault().getIconRegistry().getIcon(IProgramElement.Kind.FILE_LST).getIconResource()); + this.add(buildItem); } } } diff --git a/ajde/src/main/java/org/aspectj/ajde/ui/swing/OptionsFrame.java b/ajde/src/main/java/org/aspectj/ajde/ui/swing/OptionsFrame.java index 3eb852346..1729ac87a 100644 --- a/ajde/src/main/java/org/aspectj/ajde/ui/swing/OptionsFrame.java +++ b/ajde/src/main/java/org/aspectj/ajde/ui/swing/OptionsFrame.java @@ -160,9 +160,9 @@ public class OptionsFrame extends JFrame { private void saveOptions() { try { Component[] components = main_tabbedPane.getComponents(); - for (int i = 0; i < components.length; i++) { - if (components[i] instanceof OptionsPanel) { - ((OptionsPanel)components[i]).saveOptions(); + for (Component component : components) { + if (component instanceof OptionsPanel) { + ((OptionsPanel) component).saveOptions(); } } } catch (IOException ioe) { diff --git a/ajde/src/main/java/org/aspectj/ajde/ui/swing/StructureViewPanel.java b/ajde/src/main/java/org/aspectj/ajde/ui/swing/StructureViewPanel.java index c1435051a..add41298c 100644 --- a/ajde/src/main/java/org/aspectj/ajde/ui/swing/StructureViewPanel.java +++ b/ajde/src/main/java/org/aspectj/ajde/ui/swing/StructureViewPanel.java @@ -63,8 +63,8 @@ public class StructureViewPanel extends JPanel implements StructureViewRenderer public StructureViewPanel(java.util.List structureViews) { // this.structureViews = structureViews; - for (Iterator it = structureViews.iterator(); it.hasNext(); ) { - initView((StructureView)it.next()); + for (Object structureView : structureViews) { + initView((StructureView) structureView); } currentView = (StructureView)structureViews.get(0); structureToolBar_panel = new BrowserStructureViewToolPanel(structureViews, currentView, this); diff --git a/ajde/src/main/java/org/aspectj/ajde/ui/swing/SwingTreeViewNode.java b/ajde/src/main/java/org/aspectj/ajde/ui/swing/SwingTreeViewNode.java index 3e3f08935..ef756f6e4 100644 --- a/ajde/src/main/java/org/aspectj/ajde/ui/swing/SwingTreeViewNode.java +++ b/ajde/src/main/java/org/aspectj/ajde/ui/swing/SwingTreeViewNode.java @@ -48,10 +48,10 @@ public class SwingTreeViewNode extends DefaultMutableTreeNode implements IStruct this.kind = Kind.DECLARATION; if (children != null) { - for (Iterator it = children.iterator(); it.hasNext(); ) { - SwingTreeViewNode child = (SwingTreeViewNode)it.next(); + for (Object o : children) { + SwingTreeViewNode child = (SwingTreeViewNode) o; if (StructureViewNodeFactory.acceptNode(programElement, child.getStructureNode())) { - super.add(child); + super.add(child); } } } diff --git a/ajde/src/main/java/org/aspectj/ajde/ui/swing/TreeViewBuildConfigEditor.java b/ajde/src/main/java/org/aspectj/ajde/ui/swing/TreeViewBuildConfigEditor.java index 3d332c865..02f9aaf8f 100644 --- a/ajde/src/main/java/org/aspectj/ajde/ui/swing/TreeViewBuildConfigEditor.java +++ b/ajde/src/main/java/org/aspectj/ajde/ui/swing/TreeViewBuildConfigEditor.java @@ -107,10 +107,9 @@ public class TreeViewBuildConfigEditor extends JPanel implements BuildConfigEdit private ConfigTreeNode buildTree(BuildConfigNode node) { ConfigTreeNode treeNode = new ConfigTreeNode(node); - for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) { - BuildConfigNode childNode = (BuildConfigNode)it.next(); - treeNode.add(buildTree(childNode)); - } + for (BuildConfigNode childNode : node.getChildren()) { + treeNode.add(buildTree(childNode)); + } return treeNode; } diff --git a/ajde/src/test/java/org/aspectj/ajde/AjdeTestCase.java b/ajde/src/test/java/org/aspectj/ajde/AjdeTestCase.java index 0c5c5c306..f1d979181 100644 --- a/ajde/src/test/java/org/aspectj/ajde/AjdeTestCase.java +++ b/ajde/src/test/java/org/aspectj/ajde/AjdeTestCase.java @@ -91,8 +91,7 @@ public abstract class AjdeTestCase extends TestCase { String contents[] = from.list(); if (contents == null) return; - for (int i = 0; i < contents.length; i++) { - String string = contents[i]; + for (String string : contents) { File f = new File(from, string); File t = new File(to, string); diff --git a/ajde/src/test/java/org/aspectj/ajde/ExtensionTest.java b/ajde/src/test/java/org/aspectj/ajde/ExtensionTest.java index 43d75f8d4..a8ce3d922 100644 --- a/ajde/src/test/java/org/aspectj/ajde/ExtensionTest.java +++ b/ajde/src/test/java/org/aspectj/ajde/ExtensionTest.java @@ -78,8 +78,7 @@ public class ExtensionTest extends AjcTestCase { private IProgramElement getChild(IProgramElement parent, String s) { List<IProgramElement> kids = parent.getChildren(); - for (Iterator<IProgramElement> iter = kids.iterator(); iter.hasNext();) { - IProgramElement element = (IProgramElement) iter.next(); + for (IProgramElement element : kids) { if (element.getName().indexOf(s) != -1) return element; } @@ -97,8 +96,8 @@ public class ExtensionTest extends AjcTestCase { } if (ipe.getChildren() != null) { List kids = ipe.getChildren(); - for (Iterator iter = kids.iterator(); iter.hasNext();) { - IProgramElement element = (IProgramElement) iter.next(); + for (Object kid : kids) { + IProgramElement element = (IProgramElement) kid; findChild(s, element); } } @@ -113,8 +112,8 @@ public class ExtensionTest extends AjcTestCase { System.out.println(ipe.toLabelString());// getName()); if (ipe.getChildren() != null) { List kids = ipe.getChildren(); - for (Iterator iter = kids.iterator(); iter.hasNext();) { - IProgramElement element = (IProgramElement) iter.next(); + for (Object kid : kids) { + IProgramElement element = (IProgramElement) kid; walkit(element, indent + 2); } } diff --git a/ajde/src/test/java/org/aspectj/ajde/ui/StructureViewManagerTest.java b/ajde/src/test/java/org/aspectj/ajde/ui/StructureViewManagerTest.java index 0c1aa53ef..eca56feec 100644 --- a/ajde/src/test/java/org/aspectj/ajde/ui/StructureViewManagerTest.java +++ b/ajde/src/test/java/org/aspectj/ajde/ui/StructureViewManagerTest.java @@ -98,8 +98,7 @@ public class StructureViewManagerTest extends AjdeTestCase { } private void testModelIntegrityHelper(IProgramElement node) throws Exception { - for (Iterator it = node.getChildren().iterator(); it.hasNext();) { - IProgramElement child = (IProgramElement) it.next(); + for (IProgramElement child : node.getChildren()) { if (node == child.getParent()) { testModelIntegrityHelper(child); } else { diff --git a/ajde/src/test/java/org/aspectj/ajde/ui/utils/TestBuildProgressMonitor.java b/ajde/src/test/java/org/aspectj/ajde/ui/utils/TestBuildProgressMonitor.java index 935dcc363..6ccddefc0 100644 --- a/ajde/src/test/java/org/aspectj/ajde/ui/utils/TestBuildProgressMonitor.java +++ b/ajde/src/test/java/org/aspectj/ajde/ui/utils/TestBuildProgressMonitor.java @@ -77,18 +77,18 @@ public class TestBuildProgressMonitor implements IBuildProgressMonitor { } public boolean containsMessage(String prefix,String distinguishingMarks) { - for (Iterator iter = messagesReceived.iterator(); iter.hasNext();) { - String element = (String) iter.next(); + for (Object o : messagesReceived) { + String element = (String) o; if (element.startsWith(prefix) && - element.indexOf(distinguishingMarks)!=-1) return true; + element.indexOf(distinguishingMarks) != -1) return true; } return false; } public void dumpMessages() { System.out.println("ProgressMonitorMessages"); - for (Iterator iter = messagesReceived.iterator(); iter.hasNext();) { - String element = (String) iter.next(); + for (Object o : messagesReceived) { + String element = (String) o; System.out.println(element); } } diff --git a/ajde/src/test/java/org/aspectj/ajde/ui/utils/TestCompilerConfiguration.java b/ajde/src/test/java/org/aspectj/ajde/ui/utils/TestCompilerConfiguration.java index 04a73d2f4..a6fec514d 100644 --- a/ajde/src/test/java/org/aspectj/ajde/ui/utils/TestCompilerConfiguration.java +++ b/ajde/src/test/java/org/aspectj/ajde/ui/utils/TestCompilerConfiguration.java @@ -116,17 +116,17 @@ public class TestCompilerConfiguration implements ICompilerConfiguration { /* Allow the user to override the testProjectPath by using sourceRoots */ File[] srcBase = new File[] { new File(projectPath + File.separator + srcDirName) }; - for (int j = 0; j < srcBase.length; j++) { - File[] fromResources = FileUtil.listFiles(srcBase[j], new FileFilter() { + for (File file : srcBase) { + File[] fromResources = FileUtil.listFiles(file, new FileFilter() { public boolean accept(File pathname) { String name = pathname.getName().toLowerCase(); return !name.endsWith(".class") && !name.endsWith(".java") && !name.endsWith(".aj") && !name.endsWith(".lst") && !name.endsWith(".jar"); } }); - for (int i = 0; i < fromResources.length; i++) { - String normPath = FileUtil.normalizedPath(fromResources[i], srcBase[j]); - sourcePathResources.put(normPath, fromResources[i]); + for (File fromResource : fromResources) { + String normPath = FileUtil.normalizedPath(fromResource, file); + sourcePathResources.put(normPath, fromResource); } } |