diff options
author | Carsten Hammer | 2019-06-16 16:29:17 +0000 |
---|---|---|
committer | Karsten Thoms | 2019-10-14 13:00:37 +0000 |
commit | a8dfbc50ee3ab76bbdbb9b45e5182d0b08b7ec9e (patch) | |
tree | 2ea6acb92a8b921f20a92b2595332af7d71e4af6 | |
parent | 154876b4fe661e138d81eebed0fe2e41da7da86a (diff) | |
download | eclipse.platform.debug-a8dfbc50ee3ab76bbdbb9b45e5182d0b08b7ec9e.tar.gz eclipse.platform.debug-a8dfbc50ee3ab76bbdbb9b45e5182d0b08b7ec9e.tar.xz eclipse.platform.debug-a8dfbc50ee3ab76bbdbb9b45e5182d0b08b7ec9e.zip |
Use jdk 5 for-each loop (Part 1)
Replace simple uses of Iterator with a corresponding for-each loop. Also
add missing braces on loops as necessary.
Change-Id: I6c75e02ff88e29f6007356616dc098f6a1164a64
Signed-off-by: Carsten Hammer <carsten.hammer@t-online.de>
42 files changed, 178 insertions, 232 deletions
diff --git a/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/launchConfigurations/BackgroundResourceRefresher.java b/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/launchConfigurations/BackgroundResourceRefresher.java index 396fa8001..968ae1441 100644 --- a/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/launchConfigurations/BackgroundResourceRefresher.java +++ b/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/launchConfigurations/BackgroundResourceRefresher.java @@ -60,8 +60,7 @@ public class BackgroundResourceRefresher implements IDebugEventSetListener { @Override public void handleDebugEvents(DebugEvent[] events) { - for (int i = 0; i < events.length; i++) { - DebugEvent event = events[i]; + for (DebugEvent event : events) { if (event.getSource() == fProcess && event.getKind() == DebugEvent.TERMINATE) { DebugPlugin.getDefault().removeDebugEventListener(this); refresh(); diff --git a/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/launchConfigurations/ProgramLaunchDelegate.java b/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/launchConfigurations/ProgramLaunchDelegate.java index 8747d162e..9f6fdaab5 100644 --- a/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/launchConfigurations/ProgramLaunchDelegate.java +++ b/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/launchConfigurations/ProgramLaunchDelegate.java @@ -179,9 +179,9 @@ public class ProgramLaunchDelegate extends LaunchConfigurationDelegate { return IExternalToolConstants.EMPTY_STRING; } StringBuilder buf = new StringBuilder(); - for (int i = 0; i < commandLine.length; i++) { + for (String c : commandLine) { buf.append(' '); - char[] characters = commandLine[i].toCharArray(); + char[] characters = c.toCharArray(); StringBuilder command = new StringBuilder(); boolean containsSpace = false; for (int j = 0; j < characters.length; j++) { diff --git a/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/model/BuilderCoreUtils.java b/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/model/BuilderCoreUtils.java index 01bda1d3a..d16b697cf 100644 --- a/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/model/BuilderCoreUtils.java +++ b/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/model/BuilderCoreUtils.java @@ -197,8 +197,7 @@ public class BuilderCoreUtils { // The goal here is to not change the storage format of old, // unedited builders. ICommand[] commands = project.getDescription().getBuildSpec(); - for (int i = 0; i < commands.length; i++) { - ICommand projectCommand = commands[i]; + for (ICommand projectCommand : commands) { String name = ExternalToolMigration .getNameFromCommandArgs(projectCommand.getArguments()); if (name != null && name.equals(config.getName())) { diff --git a/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/model/ExternalToolBuilder.java b/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/model/ExternalToolBuilder.java index 37d7d6fa2..16ac512a8 100644 --- a/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/model/ExternalToolBuilder.java +++ b/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/model/ExternalToolBuilder.java @@ -258,13 +258,13 @@ public final class ExternalToolBuilder extends IncrementalProjectBuilder { } private boolean buildScopeIndicatesBuild(IResource[] resources) { - for (int i = 0; i < resources.length; i++) { - IResourceDelta delta = getDelta(resources[i].getProject()); + for (IResource resource : resources) { + IResourceDelta delta = getDelta(resource.getProject()); if (delta == null) { //project just added to the workspace..no previous build tree return true; } - IPath path= resources[i].getProjectRelativePath(); + IPath path = resource.getProjectRelativePath(); IResourceDelta change= delta.findMember(path); if (change != null) { final boolean[] trueChange= new boolean[1]; diff --git a/org.eclipse.core.variables/src/org/eclipse/core/internal/variables/StringVariableManager.java b/org.eclipse.core.variables/src/org/eclipse/core/internal/variables/StringVariableManager.java index fa980503a..533ebb8f1 100644 --- a/org.eclipse.core.variables/src/org/eclipse/core/internal/variables/StringVariableManager.java +++ b/org.eclipse.core.variables/src/org/eclipse/core/internal/variables/StringVariableManager.java @@ -222,8 +222,7 @@ public class StringVariableManager implements IStringVariableManager, IPreferenc private void loadDynamicVariables() { IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(VariablesPlugin.PI_CORE_VARIABLES, EXTENSION_POINT_DYNAMIC_VARIABLES); IConfigurationElement elements[]= point.getConfigurationElements(); - for (int i = 0; i < elements.length; i++) { - IConfigurationElement element = elements[i]; + for (IConfigurationElement element : elements) { String name= element.getAttribute(ATTR_NAME); if (name == null) { VariablesPlugin.logMessage(NLS.bind("Variable extension missing required 'name' attribute: {0}", new String[] {element.getDeclaringExtension().getLabel()}), null); //$NON-NLS-1$ @@ -236,7 +235,7 @@ public class StringVariableManager implements IStringVariableManager, IPreferenc DynamicVariable oldVariable = (DynamicVariable)old; VariablesPlugin.logMessage(NLS.bind("Dynamic variable extension from bundle ''{0}'' overrides existing extension variable ''{1}'' from bundle ''{2}''", //$NON-NLS-1$ new String[] {element.getDeclaringExtension().getContributor().getName(),oldVariable.getName(), - oldVariable.getConfigurationElement().getDeclaringExtension().getContributor().getName()}), null); + oldVariable.getConfigurationElement().getDeclaringExtension().getContributor().getName()}), null); } } } @@ -247,8 +246,7 @@ public class StringVariableManager implements IStringVariableManager, IPreferenc private void loadContributedValueVariables() { IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(VariablesPlugin.PI_CORE_VARIABLES, EXTENSION_POINT_VALUE_VARIABLES); IConfigurationElement elements[]= point.getConfigurationElements(); - for (int i = 0; i < elements.length; i++) { - IConfigurationElement element = elements[i]; + for (IConfigurationElement element : elements) { String name= element.getAttribute(ATTR_NAME); if (name == null) { VariablesPlugin.logMessage(NLS.bind("Variable extension missing required 'name' attribute: {0}", new String[] {element.getDeclaringExtension().getLabel()}), null); //$NON-NLS-1$ @@ -263,7 +261,7 @@ public class StringVariableManager implements IStringVariableManager, IPreferenc StringVariable oldVariable = (StringVariable)old; VariablesPlugin.logMessage(NLS.bind("Contributed variable extension from bundle ''{0}'' overrides existing extension variable ''{1}'' from bundle ''{2}''", //$NON-NLS-1$ new String[] {element.getDeclaringExtension().getContributor().getName(),oldVariable.getName(), - oldVariable.getConfigurationElement().getDeclaringExtension().getContributor().getName()}), null); + oldVariable.getConfigurationElement().getDeclaringExtension().getContributor().getName()}), null); } } } @@ -363,15 +361,13 @@ public class StringVariableManager implements IStringVariableManager, IPreferenc public synchronized void addVariables(IValueVariable[] variables) throws CoreException { initialize(); MultiStatus status = new MultiStatus(VariablesPlugin.getUniqueIdentifier(), VariablesPlugin.INTERNAL_ERROR, VariablesMessages.StringVariableManager_26, null); - for (int i = 0; i < variables.length; i++) { - IValueVariable variable = variables[i]; + for (IValueVariable variable : variables) { if (getValueVariable(variable.getName()) != null) { status.add(new Status(IStatus.ERROR, VariablesPlugin.getUniqueIdentifier(), VariablesPlugin.INTERNAL_ERROR, NLS.bind(VariablesMessages.StringVariableManager_27, new String[]{variable.getName()}), null)); } } if (status.isOK()) { - for (int i = 0; i < variables.length; i++) { - IValueVariable variable = variables[i]; + for (IValueVariable variable : variables) { fValueVariables.put(variable.getName(), variable); } IValueVariable[] copy = new IValueVariable[variables.length]; @@ -386,8 +382,7 @@ public class StringVariableManager implements IStringVariableManager, IPreferenc public synchronized void removeVariables(IValueVariable[] variables) { initialize(); List<IValueVariable> removed = new ArrayList<>(variables.length); - for (int i = 0; i < variables.length; i++) { - IValueVariable variable = variables[i]; + for (IValueVariable variable : variables) { if (fValueVariables.remove(variable.getName()) != null) { removed.add(variable); } @@ -434,8 +429,7 @@ public class StringVariableManager implements IStringVariableManager, IPreferenc Document document= getDocument(); Element rootElement= document.createElement(VALUE_VARIABLES_TAG); document.appendChild(rootElement); - for (int i = 0; i < variables.length; i++) { - IValueVariable variable = variables[i]; + for (IValueVariable variable : variables) { if (!variable.isReadOnly()){ // don't persist read-only variables or un-initialized contributed variables if (!variable.isContributed() || ((ContributedValueVariable)variable).isInitialized()) { diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/core/DebugPlugin.java b/org.eclipse.debug.core/core/org/eclipse/debug/core/DebugPlugin.java index acbef267d..599fdc7f7 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/core/DebugPlugin.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/core/DebugPlugin.java @@ -1055,8 +1055,7 @@ public class DebugPlugin extends Plugin { IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(DebugPlugin.PI_DEBUG_CORE, EXTENSION_POINT_STATUS_HANDLERS); IConfigurationElement[] infos= extensionPoint.getConfigurationElements(); fStatusHandlers = new HashMap<>(infos.length); - for (int i= 0; i < infos.length; i++) { - IConfigurationElement configurationElement = infos[i]; + for (IConfigurationElement configurationElement : infos) { String id = configurationElement.getAttribute("plugin"); //$NON-NLS-1$ String code = configurationElement.getAttribute("code"); //$NON-NLS-1$ @@ -1083,17 +1082,16 @@ public class DebugPlugin extends Plugin { IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(DebugPlugin.PI_DEBUG_CORE, EXTENSION_POINT_PROCESS_FACTORIES); IConfigurationElement[] infos= extensionPoint.getConfigurationElements(); fProcessFactories = new HashMap<>(infos.length); - for (int i= 0; i < infos.length; i++) { - IConfigurationElement configurationElement = infos[i]; + for (IConfigurationElement configurationElement : infos) { String id = configurationElement.getAttribute("id"); //$NON-NLS-1$ String clss = configurationElement.getAttribute("class"); //$NON-NLS-1$ if (id != null && clss != null) { - fProcessFactories.put(id, configurationElement); + fProcessFactories.put(id, configurationElement); } else { // invalid process factory - String badDefiner= infos[i].getContributor().getName(); + String badDefiner = configurationElement.getContributor().getName(); log(new Status(IStatus.ERROR, DebugPlugin.PI_DEBUG_CORE, ERROR, MessageFormat.format(DebugCoreMessages.DebugPlugin_4, new Object[] { - badDefiner, id }), null)); + badDefiner, id }), null)); } } } @@ -1221,8 +1219,8 @@ public class DebugPlugin extends Plugin { fMode = NOTIFY_EVENTS; if (DebugOptions.DEBUG_EVENTS) { - for (int i = 0; i < fEvents.length; i++) { - DebugOptions.trace(fEvents[i].toString()); + for (DebugEvent event : fEvents) { + DebugOptions.trace(event.toString()); } } for (IDebugEventSetListener iDebugEventSetListener : fEventListeners) { diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/core/Launch.java b/org.eclipse.debug.core/core/org/eclipse/debug/core/Launch.java index 0f2cf17a3..504274106 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/core/Launch.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/core/Launch.java @@ -259,8 +259,7 @@ public class Launch extends PlatformObject implements ILaunch, IDisconnect, ILau //stop targets first to free up and sockets, etc held by the target // terminate or disconnect debug target if it is still alive IDebugTarget[] targets = getDebugTargets(); - for (int i = 0; i < targets.length; i++) { - IDebugTarget target= targets[i]; + for (IDebugTarget target : targets) { if (target != null) { if (target.canTerminate()) { try { @@ -282,8 +281,7 @@ public class Launch extends PlatformObject implements ILaunch, IDisconnect, ILau //second kill the underlying process // terminate the system processes IProcess[] processes = getProcesses(); - for (int i = 0; i < processes.length; i++) { - IProcess process = processes[i]; + for (IProcess process : processes) { if (process.canTerminate()) { try { process.terminate(); @@ -452,8 +450,8 @@ public class Launch extends PlatformObject implements ILaunch, IDisconnect, ILau */ protected void addProcesses(IProcess[] processes) { if (processes != null) { - for (int i = 0; i < processes.length; i++) { - addProcess(processes[i]); + for (IProcess process : processes) { + addProcess(process); fireChanged(); } } @@ -633,8 +631,7 @@ public class Launch extends PlatformObject implements ILaunch, IDisconnect, ILau @Override public void handleDebugEvents(DebugEvent[] events) { - for (int i = 0; i < events.length; i++) { - DebugEvent event = events[i]; + for (DebugEvent event : events) { if (event.getKind() == DebugEvent.TERMINATE) { Object object = event.getSource(); ILaunch launch = null; diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/core/RefreshUtil.java b/org.eclipse.debug.core/core/org/eclipse/debug/core/RefreshUtil.java index e053e5afb..dcd27d6bc 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/core/RefreshUtil.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/core/RefreshUtil.java @@ -125,13 +125,13 @@ public class RefreshUtil { } MultiStatus status = new MultiStatus(DebugPlugin.getUniqueIdentifier(), 0, DebugCoreMessages.RefreshingResourcesError, null); try { - for (int i = 0; i < resources.length; i++) { + for (IResource resource : resources) { if (lmonitor.isCanceled()) { break; } - if (resources[i] != null && resources[i].isAccessible()) { + if (resource != null && resource.isAccessible()) { try { - resources[i].refreshLocal(depth, null); + resource.refreshLocal(depth, null); } catch (CoreException e) { status.merge(e.getStatus()); } @@ -206,9 +206,9 @@ public class RefreshUtil { */ public static String toMemento(IResource[] resources) { XMLMemento memento = XMLMemento.createWriteRoot("resources"); //$NON-NLS-1$ - for (int i = 0; i < resources.length; i++) { + for (IResource resource : resources) { final XMLMemento itemMemento = memento.createChild(IMementoConstants.MEMENTO_ITEM); - ResourceFactory.saveState(itemMemento, resources[i]); + ResourceFactory.saveState(itemMemento, resource); } StringWriter writer = new StringWriter(); try { @@ -248,8 +248,8 @@ public class RefreshUtil { } XMLMemento[] mementos = memento.getChildren(IMementoConstants.MEMENTO_ITEM); - for (int i = 0; i < mementos.length; i++) { - resourcesList.add(ResourceFactory.createElement(mementos[i])); + for (XMLMemento m : mementos) { + resourcesList.add(ResourceFactory.createElement(m)); } return resourcesList.toArray(new IResource[resourcesList.size()]); diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/core/model/RuntimeProcess.java b/org.eclipse.debug.core/core/org/eclipse/debug/core/model/RuntimeProcess.java index 9f56edef5..e731732cb 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/core/model/RuntimeProcess.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/core/model/RuntimeProcess.java @@ -354,9 +354,9 @@ public class RuntimeProcess extends PlatformObject implements IProcess { if (adapter.equals(IDebugTarget.class)) { ILaunch launch = getLaunch(); IDebugTarget[] targets = launch.getDebugTargets(); - for (int i = 0; i < targets.length; i++) { - if (this.equals(targets[i].getProcess())) { - return (T) targets[i]; + for (IDebugTarget target : targets) { + if (this.equals(target.getProcess())) { + return (T) target; } } return null; diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/core/sourcelookup/AbstractSourceLookupDirector.java b/org.eclipse.debug.core/core/org/eclipse/debug/core/sourcelookup/AbstractSourceLookupDirector.java index 3612cb1ff..e9b395af0 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/core/sourcelookup/AbstractSourceLookupDirector.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/core/sourcelookup/AbstractSourceLookupDirector.java @@ -132,16 +132,16 @@ public abstract class AbstractSourceLookupDirector implements ISourceLookupDirec CoreException single = null; ISourceLookupParticipant[] participants = getParticipants(); try { - for(int i=0; i < participants.length; i++) { - setCurrentParticipant(participants[i]); + for (ISourceLookupParticipant participant : participants) { + setCurrentParticipant(participant); Object[] sourceArray; try { - sourceArray = participants[i].findSourceElements(fElement); + sourceArray = participant.findSourceElements(fElement); if (sourceArray !=null && sourceArray.length > 0) { if (isFindDuplicates()) { - for(int j=0; j<sourceArray.length; j++) { - if(!checkDuplicate(sourceArray[j], fSourceElements)) { - fSourceElements.add(sourceArray[j]); + for (Object s : sourceArray) { + if (!checkDuplicate(s, fSourceElements)) { + fSourceElements.add(s); } } } else { @@ -214,8 +214,8 @@ public abstract class AbstractSourceLookupDirector implements ISourceLookupDirec } fParticipants.clear(); if (fSourceContainers != null) { - for (int i = 0; i < fSourceContainers.length; i++) { - fSourceContainers[i].dispose(); + for (ISourceContainer container : fSourceContainers) { + container.dispose(); } } fSourceContainers = null; @@ -370,9 +370,8 @@ public abstract class AbstractSourceLookupDirector implements ISourceLookupDirec } rootNode.appendChild(pathNode); if(fSourceContainers !=null){ - for(int i=0; i<fSourceContainers.length; i++){ + for (ISourceContainer container : fSourceContainers) { Element node = doc.createElement(CONTAINER_NODE); - ISourceContainer container = fSourceContainers[i]; ISourceContainerType type = container.getType(); node.setAttribute(CONTAINER_TYPE_ATTR, type.getId()); node.setAttribute(CONTAINER_MEMENTO_ATTR, type.getMemento(container)); @@ -434,15 +433,14 @@ public abstract class AbstractSourceLookupDirector implements ISourceLookupDirec synchronized (this) { List<ISourceContainer> list = Arrays.asList(containers); ISourceContainer[] old = getSourceContainers(); - for (int i = 0; i < old.length; i++) { + for (ISourceContainer container : old) { // skip overlapping containers - if (!list.contains(old[i])) { - old[i].dispose(); + if (!list.contains(container)) { + container.dispose(); } } fSourceContainers = containers; - for (int i = 0; i < containers.length; i++) { - ISourceContainer container = containers[i]; + for (ISourceContainer container : containers) { container.init(this); } } @@ -450,8 +448,7 @@ public abstract class AbstractSourceLookupDirector implements ISourceLookupDirec fResolvedElements = null; // notify participants ISourceLookupParticipant[] participants = getParticipants(); - for (int i = 0; i < participants.length; i++) { - ISourceLookupParticipant participant = participants[i]; + for (ISourceLookupParticipant participant : participants) { participant.sourceContainersChanged(this); } } @@ -663,8 +660,7 @@ public abstract class AbstractSourceLookupDirector implements ISourceLookupDirec @Override public void addParticipants(ISourceLookupParticipant[] participants) { - for (int i = 0; i < participants.length; i++) { - ISourceLookupParticipant participant = participants[i]; + for (ISourceLookupParticipant participant : participants) { addSourceLookupParticipant(participant); participant.sourceContainersChanged(this); } @@ -672,8 +668,8 @@ public abstract class AbstractSourceLookupDirector implements ISourceLookupDirec @Override public void removeParticipants(ISourceLookupParticipant[] participants) { - for (int i = 0; i < participants.length; i++) { - removeSourceLookupParticipant(participants[i]); + for (ISourceLookupParticipant participant : participants) { + removeSourceLookupParticipant(participant); } } diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/core/sourcelookup/AbstractSourceLookupParticipant.java b/org.eclipse.debug.core/core/org/eclipse/debug/core/sourcelookup/AbstractSourceLookupParticipant.java index 50728d593..6a3da24a8 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/core/sourcelookup/AbstractSourceLookupParticipant.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/core/sourcelookup/AbstractSourceLookupParticipant.java @@ -58,9 +58,9 @@ public abstract class AbstractSourceLookupParticipant implements ISourceLookupPa String name = getSourceName(object); if (name != null) { ISourceContainer[] containers = getSourceContainers(); - for (int i = 0; i < containers.length; i++) { + for (ISourceContainer c : containers) { try { - ISourceContainer container = getDelegateContainer(containers[i]); + ISourceContainer container = getDelegateContainer(c); if (container != null) { Object[] objects = container.findSourceElements(name); if (objects.length > 0) { diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/core/sourcelookup/containers/CompositeSourceContainer.java b/org.eclipse.debug.core/core/org/eclipse/debug/core/sourcelookup/containers/CompositeSourceContainer.java index 7799c478c..dc45d5b69 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/core/sourcelookup/containers/CompositeSourceContainer.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/core/sourcelookup/containers/CompositeSourceContainer.java @@ -73,8 +73,7 @@ public abstract class CompositeSourceContainer extends AbstractSourceContainer { if (isFindDuplicates()) { results = new ArrayList<>(); } - for (int i = 0; i < containers.length; i++) { - ISourceContainer container = containers[i]; + for (ISourceContainer container : containers) { try { Object[] objects = container.findSourceElements(name); if (objects.length > 0) { @@ -124,8 +123,7 @@ public abstract class CompositeSourceContainer extends AbstractSourceContainer { public synchronized ISourceContainer[] getSourceContainers() throws CoreException { if (fContainers == null) { fContainers = createSourceContainers(); - for (int i = 0; i < fContainers.length; i++) { - ISourceContainer container = fContainers[i]; + for (ISourceContainer container : fContainers) { container.init(getDirector()); } } @@ -136,8 +134,7 @@ public abstract class CompositeSourceContainer extends AbstractSourceContainer { public void dispose() { super.dispose(); if (fContainers != null) { - for (int i = 0; i < fContainers.length; i++) { - ISourceContainer container = fContainers[i]; + for (ISourceContainer container : fContainers) { container.dispose(); } } diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/core/sourcelookup/containers/DirectorySourceContainer.java b/org.eclipse.debug.core/core/org/eclipse/debug/core/sourcelookup/containers/DirectorySourceContainer.java index 12bab3aa2..4e0da41cd 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/core/sourcelookup/containers/DirectorySourceContainer.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/core/sourcelookup/containers/DirectorySourceContainer.java @@ -105,8 +105,8 @@ public class DirectorySourceContainer extends CompositeSourceContainer { //check sub-folders if ((isFindDuplicates() && fSubfolders) || (sources.isEmpty() && fSubfolders)) { ISourceContainer[] containers = getSourceContainers(); - for (int i=0; i < containers.length; i++) { - Object[] objects = containers[i].findSourceElements(name); + for (ISourceContainer container : containers) { + Object[] objects = container.findSourceElements(name); if (objects == null || objects.length == 0) { continue; } @@ -150,16 +150,14 @@ public class DirectorySourceContainer extends CompositeSourceContainer { String[] files = fDirectory.list(); if (files != null) { List<ISourceContainer> dirs = new ArrayList<>(); - for (int i = 0; i < files.length; i++) { - String name = files[i]; + for (String name : files) { File file = new File(getDirectory(), name); if (file.exists() && file.isDirectory()) { dirs.add(new DirectorySourceContainer(file, true)); } } ISourceContainer[] containers = dirs.toArray(new ISourceContainer[dirs.size()]); - for (int i = 0; i < containers.length; i++) { - ISourceContainer container = containers[i]; + for (ISourceContainer container : containers) { container.init(getDirector()); } return containers; diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/core/sourcelookup/containers/ProjectSourceContainer.java b/org.eclipse.debug.core/core/org/eclipse/debug/core/sourcelookup/containers/ProjectSourceContainer.java index 7259a4504..b7bb7eef4 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/core/sourcelookup/containers/ProjectSourceContainer.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/core/sourcelookup/containers/ProjectSourceContainer.java @@ -93,9 +93,9 @@ public class ProjectSourceContainer extends ContainerSourceContainer { ISourceContainer[] folders = super.createSourceContainers(); List<ISourceContainer> all = new ArrayList<>(folders.length + projects.length); Collections.addAll(all, folders); - for (int i = 0; i < projects.length; i++) { + for (IProject p : projects) { if (project.exists() && project.isOpen()) { - ProjectSourceContainer container = new ProjectSourceContainer(projects[i], false); + ProjectSourceContainer container = new ProjectSourceContainer(p, false); container.init(getDirector()); all.add(container); } @@ -115,10 +115,10 @@ public class ProjectSourceContainer extends ContainerSourceContainer { private void getAllReferencedProjects(Set<IProject> all, IProject project) throws CoreException { IProject[] refs = project.getReferencedProjects(); - for (int i = 0; i < refs.length; i++) { - if (!all.contains(refs[i]) && refs[i].exists() && refs[i].isOpen()) { - all.add(refs[i]); - getAllReferencedProjects(all, refs[i]); + for (IProject ref : refs) { + if (!all.contains(ref) && ref.exists() && ref.isOpen()) { + all.add(ref); + getAllReferencedProjects(all, ref); } } } diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfiguration.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfiguration.java index eece9bb85..dced8da3c 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfiguration.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfiguration.java @@ -969,8 +969,7 @@ public class LaunchConfiguration extends PlatformObject implements ILaunchConfig public Collection<ILaunchConfiguration> getPrototypeChildren() throws CoreException { ILaunchConfiguration[] configurations = getLaunchManager().getLaunchConfigurations(getType()); List<ILaunchConfiguration> proteges = new ArrayList<>(); - for (int i = 0; i < configurations.length; i++) { - ILaunchConfiguration config = configurations[i]; + for (ILaunchConfiguration config : configurations) { if (this.equals(config.getPrototype())) { proteges.add(config); } diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationType.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationType.java index 5ced04ca5..2203494b1 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationType.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationType.java @@ -235,8 +235,8 @@ public class LaunchConfigurationType extends PlatformObject implements ILaunchCo LaunchDelegate delegate = null; List<Set<String>> modelist = null; Set<ILaunchDelegate> tmp = null; - for (int i = 0; i < launchDelegates.length; i++) { - delegate = launchDelegates[i]; + for (LaunchDelegate launchDelegate : launchDelegates) { + delegate = launchDelegate; modelist = delegate.getModes(); for (Set<String> modes : modelist) { tmp = fDelegates.get(modes); @@ -286,10 +286,10 @@ public class LaunchConfigurationType extends PlatformObject implements ILaunchCo //so it can be reused to try and find the source path computer if(fSourceLocator == null) { LaunchDelegate[] delegates = getLaunchDelegateExtensions(); - for(int i = 0; i < delegates.length; i++) { - fSourceLocator = delegates[i].getSourceLocatorId(); - if(fSourceLocator != null) { - fSourceProvider = delegates[i]; + for (LaunchDelegate delegate : delegates) { + fSourceLocator = delegate.getSourceLocatorId(); + if (fSourceLocator != null) { + fSourceProvider = delegate; return fSourceLocator; } } @@ -315,10 +315,10 @@ public class LaunchConfigurationType extends PlatformObject implements ILaunchCo //if not provided check all the applicable delegates for one and record the delegate if found, //so it can be reused to try and find the source path computer LaunchDelegate[] delegates = getLaunchDelegateExtensions(); - for(int i = 0; i < delegates.length; i++) { - id = delegates[i].getSourcePathComputerId(); - if(id != null) { - fSourceProvider = delegates[i]; + for (LaunchDelegate delegate : delegates) { + id = delegate.getSourcePathComputerId(); + if (id != null) { + fSourceProvider = delegate; fSourcePathComputer = DebugPlugin.getDefault().getLaunchManager().getSourcePathComputer(id); if(fSourcePathComputer != null) { return fSourcePathComputer; @@ -338,8 +338,8 @@ public class LaunchConfigurationType extends PlatformObject implements ILaunchCo fModes = new HashSet<>(); LaunchDelegate[] delegates = getLaunchDelegateExtensions(); List<Set<String>> modesets = null; - for(int i= 0; i < delegates.length; i++) { - modesets = delegates[i].getModes(); + for (LaunchDelegate delegate : delegates) { + modesets = delegate.getModes(); for (Set<String> modes : modesets) { fModes.addAll(modes); } diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationWorkingCopy.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationWorkingCopy.java index 58ed8c08b..dcd01eaa8 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationWorkingCopy.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationWorkingCopy.java @@ -659,8 +659,7 @@ public class LaunchConfigurationWorkingCopy extends LaunchConfiguration implemen if(resources != null && resources.length > 0) { paths = new ArrayList<>(resources.length); types = new ArrayList<>(resources.length); - for (int i = 0; i < resources.length; i++) { - IResource resource = resources[i]; + for (IResource resource : resources) { if(resource != null) { paths.add(resource.getFullPath().toPortableString()); types.add(Integer.valueOf(resource.getType()).toString()); diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchDelegate.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchDelegate.java index 303d37875..b592bb384 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchDelegate.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchDelegate.java @@ -130,8 +130,8 @@ public final class LaunchDelegate implements ILaunchDelegate { String modes = element.getAttribute(IConfigurationElementConstants.MODES); if (modes != null) { String[] strings = modes.split(","); //$NON-NLS-1$ - for (int i = 0; i < strings.length; i++) { - set.add(strings[i].trim()); + for (String string : strings) { + set.add(string.trim()); } } return set; @@ -144,10 +144,10 @@ public final class LaunchDelegate implements ILaunchDelegate { fPerspectiveIds = new HashMap<>(); IConfigurationElement[] children = fElement.getChildren(IConfigurationElementConstants.MODE_COMBINATION); Set<String> modeset = null; - for (int i = 0; i < children.length; i++) { - modeset = parseModes(children[i]); + for (IConfigurationElement child : children) { + modeset = parseModes(child); fLaunchModes.add(modeset); - fPerspectiveIds.put(modeset, children[i].getAttribute(IConfigurationElementConstants.PERSPECTIVE)); + fPerspectiveIds.put(modeset, child.getAttribute(IConfigurationElementConstants.PERSPECTIVE)); } //try to get the modes from the old definition and make each one //a separate set of one element @@ -155,9 +155,9 @@ public final class LaunchDelegate implements ILaunchDelegate { String modes = fElement.getAttribute(IConfigurationElementConstants.MODES); if (modes != null) { String[] strings = modes.split(","); //$NON-NLS-1$ - for (int i = 0; i < strings.length; i++) { + for (String string : strings) { modeset = new HashSet<>(); - modeset.add(strings[i].trim()); + modeset.add(string.trim()); fLaunchModes.add(modeset); } } diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/MemoryBlockManager.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/MemoryBlockManager.java index 65d9d71aa..aa3c53412 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/MemoryBlockManager.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/MemoryBlockManager.java @@ -84,8 +84,8 @@ public class MemoryBlockManager implements IMemoryBlockManager, IDebugEventSetLi if (listeners != null) { fType = update; Object[] copiedListeners= listeners.toArray(new IMemoryBlockListener[listeners.size()]); - for (int i= 0; i < copiedListeners.length; i++) { - fListener = (IMemoryBlockListener)copiedListeners[i]; + for (Object copiedListener : copiedListeners) { + fListener = (IMemoryBlockListener) copiedListener; fMemoryBlocks = memBlocks; SafeRunner.run(this); } @@ -118,11 +118,11 @@ public class MemoryBlockManager implements IMemoryBlockManager, IDebugEventSetLi if(mem.length > 0) { ArrayList<IMemoryBlock> newMemoryBlocks = new ArrayList<>(); - for (int i=0; i<mem.length; i++) { + for (IMemoryBlock m : mem) { // do not allow duplicates - if (!memoryBlocks.contains(mem[i])) { - newMemoryBlocks.add(mem[i]); - memoryBlocks.add(mem[i]); + if (!memoryBlocks.contains(m)) { + newMemoryBlocks.add(m); + memoryBlocks.add(m); // add listener for the first memory block added if (memoryBlocks.size() == 1) { DebugPlugin.getDefault().addDebugEventListener(this); @@ -144,16 +144,16 @@ public class MemoryBlockManager implements IMemoryBlockManager, IDebugEventSetLi } if(memBlocks.length > 0) { - for (int i=0; i<memBlocks.length; i++) { - memoryBlocks.remove(memBlocks[i]); + for (IMemoryBlock memBlock : memBlocks) { + memoryBlocks.remove(memBlock); // remove listener after the last memory block has been removed if (memoryBlocks.isEmpty()) { DebugPlugin.getDefault().removeDebugEventListener(this); } - if (memBlocks[i] instanceof IMemoryBlockExtension) { + if (memBlock instanceof IMemoryBlockExtension) { try { - ((IMemoryBlockExtension)memBlocks[i]).dispose(); - } catch (DebugException e) { + ((IMemoryBlockExtension) memBlock).dispose(); + }catch (DebugException e) { DebugPlugin.log(e); } } @@ -242,8 +242,8 @@ public class MemoryBlockManager implements IMemoryBlockManager, IDebugEventSetLi @Override public void handleDebugEvents(DebugEvent[] events) { - for (int i=0; i < events.length; i++) { - handleDebugEvent(events[i]); + for (DebugEvent event : events) { + handleDebugEvent(event); } } diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/PreferredDelegateModifyListener.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/PreferredDelegateModifyListener.java index c7dfd261b..fcba9059d 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/PreferredDelegateModifyListener.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/PreferredDelegateModifyListener.java @@ -36,8 +36,8 @@ public class PreferredDelegateModifyListener extends PreferenceModifyListener { LaunchManager manager = (LaunchManager)DebugPlugin.getDefault().getLaunchManager(); manager.resetPreferredDelegates(); ILaunchConfigurationType[] types = manager.getLaunchConfigurationTypes(); - for (int i = 0; i < types.length; i++) { - ((LaunchConfigurationType) types[i]).resetPreferredDelegates(); + for (ILaunchConfigurationType type : types) { + ((LaunchConfigurationType) type).resetPreferredDelegates(); } return false; } diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/StepFilterManager.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/StepFilterManager.java index a2ecfb295..115702444 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/StepFilterManager.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/StepFilterManager.java @@ -84,8 +84,7 @@ public class StepFilterManager implements ILaunchListener { public void setUseStepFilters(boolean useFilters) { Preferences.setBoolean(DebugPlugin.getUniqueIdentifier(), PREF_USE_STEP_FILTERS, useFilters, null); ILaunch[] launchs = DebugPlugin.getDefault().getLaunchManager().getLaunches(); - for (int i = 0; i < launchs.length; i++) { - ILaunch launch = launchs[i]; + for (ILaunch launch : launchs) { launchChanged(launch); } } diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/ForEachCommand.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/ForEachCommand.java index a890c4c95..a1b418f4d 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/ForEachCommand.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/ForEachCommand.java @@ -28,8 +28,8 @@ public abstract class ForEachCommand extends AbstractDebugCommand { @Override protected void doExecute(Object[] targets, IProgressMonitor monitor, IRequest request) throws CoreException { - for (int i = 0; i < targets.length; i++) { - execute(targets[i]); + for (Object target : targets) { + execute(target); monitor.worked(1); } } @@ -38,8 +38,8 @@ public abstract class ForEachCommand extends AbstractDebugCommand { @Override protected boolean isExecutable(Object[] targets, IProgressMonitor monitor, IEnabledStateRequest request) throws CoreException { - for (int i = 0; i < targets.length; i++) { - if (!isExecutable(targets[i])) { + for (Object target : targets) { + if (!isExecutable(target)) { return false; } monitor.worked(1); diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/StepCommand.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/StepCommand.java index dc03bf01a..55f8ac79f 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/StepCommand.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/StepCommand.java @@ -35,8 +35,8 @@ public abstract class StepCommand extends AbstractDebugCommand { @Override protected void doExecute(Object[] targets, IProgressMonitor monitor, IRequest request) throws CoreException { - for (int i = 0; i < targets.length; i++) { - step(targets[i]); + for (Object target : targets) { + step(target); } } @@ -45,8 +45,8 @@ public abstract class StepCommand extends AbstractDebugCommand { @Override protected boolean isExecutable(Object[] targets, IProgressMonitor monitor, IEnabledStateRequest collector) throws CoreException { if (isThreadCompatible(targets)) { - for (int i = 0; i < targets.length; i++) { - if (!isSteppable(targets[i])) { + for (Object target : targets) { + if (!isSteppable(target)) { return false; } } @@ -64,8 +64,7 @@ public abstract class StepCommand extends AbstractDebugCommand { } // check if frames from same thread Set<IThread> threads = new HashSet<>(targets.length); - for (int i = 0; i < targets.length; i++) { - Object object = targets[i]; + for (Object object : targets) { IStackFrame frame = null; if (object instanceof IStackFrame) { frame = (IStackFrame) object; diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/StepFiltersCommand.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/StepFiltersCommand.java index 7ac3e1cea..191be6f80 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/StepFiltersCommand.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/commands/StepFiltersCommand.java @@ -72,8 +72,7 @@ public class StepFiltersCommand extends ForEachCommand implements IStepFiltersHa return; } IStepFilters[] filters = (IStepFilters[]) target; - for (int i = 0; i < filters.length; i++) { - IStepFilters filter = filters[i]; + for (IStepFilters filter : filters) { filter.setStepFiltersEnabled(DebugPlugin.isUseStepFilters()); } } @@ -81,8 +80,7 @@ public class StepFiltersCommand extends ForEachCommand implements IStepFiltersHa @Override protected boolean isExecutable(Object target) { IStepFilters[] filters = (IStepFilters[]) target; - for (int i = 0; i < filters.length; i++) { - IStepFilters filter = filters[i]; + for (IStepFilters filter : filters) { if (filter == null || !filter.supportsStepFilters()) { return false; } diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/groups/GroupLaunchConfigurationDelegate.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/groups/GroupLaunchConfigurationDelegate.java index 6a5c79613..153bd3886 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/groups/GroupLaunchConfigurationDelegate.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/groups/GroupLaunchConfigurationDelegate.java @@ -286,10 +286,9 @@ public class GroupLaunchConfigurationDelegate extends LaunchConfigurationDelegat protected static ILaunchConfiguration findLaunchConfiguration(String name) throws CoreException { ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager(); ILaunchConfiguration[] launchConfigurations = launchManager.getLaunchConfigurations(); - for (int i = 0; i < launchConfigurations.length; i++) { - ILaunchConfiguration lConf = launchConfigurations[i]; - if (lConf.getName().equals(name)) { - return lConf; + for (ILaunchConfiguration config : launchConfigurations) { + if (config.getName().equals(name)) { + return config; } } return null; diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/sourcelookup/SourceLookupUtils.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/sourcelookup/SourceLookupUtils.java index 92c019db8..ea44ed1c5 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/sourcelookup/SourceLookupUtils.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/sourcelookup/SourceLookupUtils.java @@ -107,8 +107,7 @@ public class SourceLookupUtils { @Override public void launchesRemoved(ILaunch[] launches) { - for (int i = 0; i < launches.length; i++) { - ILaunch launch = launches[i]; + for (ILaunch launch : launches) { if (!launch.isTerminated()) { SourceLookupUtils.closeArchives(); return; diff --git a/org.eclipse.debug.examples.memory/src/org/eclipse/debug/examples/internal/memory/engine/SampleEngine.java b/org.eclipse.debug.examples.memory/src/org/eclipse/debug/examples/internal/memory/engine/SampleEngine.java index eca5fbf46..de6a8e67d 100644 --- a/org.eclipse.debug.examples.memory/src/org/eclipse/debug/examples/internal/memory/engine/SampleEngine.java +++ b/org.eclipse.debug.examples.memory/src/org/eclipse/debug/examples/internal/memory/engine/SampleEngine.java @@ -170,9 +170,9 @@ public class SampleEngine { MemoryByte[] bytes = unit.getBytes(); - for (int i = 0; i < bytes.length; i++) { - bytes[i].setChanged(false); - bytes[i].setHistoryKnown(true); + for (MemoryByte b : bytes) { + b.setChanged(false); + b.setHistoryKnown(true); } unit.setBytes(bytes); diff --git a/org.eclipse.debug.examples.mixedmode/src/org/eclipse/debug/internal/examples/mixedmode/ClearPreferredDelegatesHandler.java b/org.eclipse.debug.examples.mixedmode/src/org/eclipse/debug/internal/examples/mixedmode/ClearPreferredDelegatesHandler.java index 5d6ac3b98..a41543482 100644 --- a/org.eclipse.debug.examples.mixedmode/src/org/eclipse/debug/internal/examples/mixedmode/ClearPreferredDelegatesHandler.java +++ b/org.eclipse.debug.examples.mixedmode/src/org/eclipse/debug/internal/examples/mixedmode/ClearPreferredDelegatesHandler.java @@ -35,12 +35,12 @@ public class ClearPreferredDelegatesHandler extends AbstractHandler { ILaunchConfigurationType[] types = lm.getLaunchConfigurationTypes(); Set<Set<String>> modes = null; Set<String> mode = null; - for (int i = 0; i < types.length; i++) { - modes = types[i].getSupportedModeCombinations(); + for (ILaunchConfigurationType type : types) { + modes = type.getSupportedModeCombinations(); for (Iterator<Set<String>> iter = modes.iterator(); iter.hasNext();) { mode = iter.next(); try { - types[i].setPreferredDelegate(mode, null); + type.setPreferredDelegate(mode, null); } catch (CoreException ce) { // /do nothing } diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/AbstractConsole.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/AbstractConsole.java index 5b0d7009f..3539baa6a 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/console/AbstractConsole.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/console/AbstractConsole.java @@ -59,8 +59,7 @@ public abstract class AbstractConsole implements IConsole { @Override public void consolesAdded(IConsole[] consoles) { - for (int i = 0; i < consoles.length; i++) { - IConsole console = consoles[i]; + for (IConsole console : consoles) { if (console == AbstractConsole.this) { initialize(); } @@ -70,8 +69,7 @@ public abstract class AbstractConsole implements IConsole { @Override public void consolesRemoved(IConsole[] consoles) { - for (int i = 0; i < consoles.length; i++) { - IConsole console = consoles[i]; + for (IConsole console : consoles) { if (console == AbstractConsole.this) { ConsolePlugin.getDefault().getConsoleManager().removeConsoleListener(this); destroy(); diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsole.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsole.java index e0cf26783..3f511fc65 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsole.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsole.java @@ -571,8 +571,8 @@ public abstract class TextConsole extends AbstractConsole { IDocument doc = getDocument(); if (doc != null) { Position[] positions = doc.getPositions(ConsoleHyperlinkPosition.HYPER_LINK_CATEGORY); - for (int i = 0; i < positions.length; i++) { - ConsoleHyperlinkPosition position = (ConsoleHyperlinkPosition)positions[i]; + for (Position p : positions) { + ConsoleHyperlinkPosition position = (ConsoleHyperlinkPosition) p; if (position.getHyperLink().equals(link)) { return new Region(position.getOffset(), position.getLength()); } diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsoleViewer.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsoleViewer.java index c5ffa14bd..32484e794 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsoleViewer.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsoleViewer.java @@ -388,8 +388,7 @@ public class TextConsoleViewer extends SourceViewer implements LineStyleListener Position[] overlap = findPosition(offset, length, positions); Color color = JFaceColors.getHyperlinkText(Display.getCurrent()); if (overlap != null) { - for (int i = 0; i < overlap.length; i++) { - Position position = overlap[i]; + for (Position position : overlap) { StyleRange linkRange = new StyleRange(position.offset, position.length, color, null); linkRange.underline = true; overrideStyleRange(ranges, linkRange); diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleManager.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleManager.java index 59ea1d431..911a1e71b 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleManager.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleManager.java @@ -107,8 +107,7 @@ public class ConsoleManager implements IConsoleManager { } IWorkbenchWindow[] workbenchWindows = PlatformUI.getWorkbench().getWorkbenchWindows(); - for (int i = 0; i < workbenchWindows.length; i++) { - IWorkbenchWindow window = workbenchWindows[i]; + for (IWorkbenchWindow window : workbenchWindows) { if (window != null) { IWorkbenchPage page = window.getActivePage(); if (page != null) { @@ -204,8 +203,7 @@ public class ConsoleManager implements IConsoleManager { public void addConsoles(IConsole[] consoles) { List<IConsole> added = new ArrayList<>(consoles.length); synchronized (fConsoles) { - for (int i = 0; i < consoles.length; i++) { - IConsole console = consoles[i]; + for (IConsole console : consoles) { if(console instanceof TextConsole) { TextConsole ioconsole = (TextConsole)console; createPatternMatchListeners(ioconsole); @@ -225,8 +223,7 @@ public class ConsoleManager implements IConsoleManager { public void removeConsoles(IConsole[] consoles) { List<IConsole> removed = new ArrayList<>(consoles.length); synchronized (fConsoles) { - for (int i = 0; i < consoles.length; i++) { - IConsole console = consoles[i]; + for (IConsole console : consoles) { if (fConsoles.remove(console)) { removed.add(console); } @@ -390,8 +387,7 @@ public class ConsoleManager implements IConsoleManager { fPatternMatchListeners = new ArrayList<>(); IExtensionPoint extensionPoint= Platform.getExtensionRegistry().getExtensionPoint(ConsolePlugin.getUniqueIdentifier(), IConsoleConstants.EXTENSION_POINT_CONSOLE_PATTERN_MATCH_LISTENERS); IConfigurationElement[] elements = extensionPoint.getConfigurationElements(); - for (int i = 0; i < elements.length; i++) { - IConfigurationElement config = elements[i]; + for (IConfigurationElement config : elements) { PatternMatchListenerExtension extension = new PatternMatchListenerExtension(config); fPatternMatchListeners.add(extension); } @@ -433,15 +429,13 @@ public class ConsoleManager implements IConsoleManager { fPageParticipants = new ArrayList<>(); IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(ConsolePlugin.getUniqueIdentifier(), IConsoleConstants.EXTENSION_POINT_CONSOLE_PAGE_PARTICIPANTS); IConfigurationElement[] elements = extensionPoint.getConfigurationElements(); - for(int i = 0; i < elements.length; i++) { - IConfigurationElement config = elements[i]; + for (IConfigurationElement config : elements) { ConsolePageParticipantExtension extension = new ConsolePageParticipantExtension(config); fPageParticipants.add(extension); } } ArrayList<IConsolePageParticipant> list = new ArrayList<>(); - for (Iterator<ConsolePageParticipantExtension> i = fPageParticipants.iterator(); i.hasNext();) { - ConsolePageParticipantExtension extension = i.next(); + for (ConsolePageParticipantExtension extension : fPageParticipants) { try { if (extension.isEnabledFor(console)) { list.add(extension.createDelegate()); @@ -461,8 +455,8 @@ public class ConsoleManager implements IConsoleManager { fConsoleFactoryExtensions = new ArrayList<>(); IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(ConsolePlugin.getUniqueIdentifier(), IConsoleConstants.EXTENSION_POINT_CONSOLE_FACTORIES); IConfigurationElement[] configurationElements = extensionPoint.getConfigurationElements(); - for (int i = 0; i < configurationElements.length; i++) { - fConsoleFactoryExtensions.add(new ConsoleFactoryExtension(configurationElements[i])); + for (IConfigurationElement configurationElement : configurationElements) { + fConsoleFactoryExtensions.add(new ConsoleFactoryExtension(configurationElement)); } } return fConsoleFactoryExtensions.toArray(new ConsoleFactoryExtension[0]); diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsolePatternMatcher.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsolePatternMatcher.java index e742ad59f..97dbab694 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsolePatternMatcher.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsolePatternMatcher.java @@ -83,11 +83,11 @@ public class ConsolePatternMatcher implements IDocumentListener { synchronized (fPatterns) { patterns = fPatterns.toArray(); } - for (int i = 0; i < patterns.length; i++) { + for (Object pattern : patterns) { if (monitor.isCanceled()) { break; } - CompiledPatternMatchListener notifier = (CompiledPatternMatchListener) patterns[i]; + CompiledPatternMatchListener notifier = (CompiledPatternMatchListener) pattern; int baseOffset = notifier.end; int lengthToSearch = endOfSearch - baseOffset; if (lengthToSearch > 0) { diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleView.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleView.java index e0985b17b..b6730b2dd 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleView.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleView.java @@ -329,8 +329,8 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL // initialize page participants IConsolePageParticipant[] consoleParticipants = ((ConsoleManager)getConsoleManager()).getPageParticipants(console); final ListenerList<IConsolePageParticipant> participants = new ListenerList<>(); - for (int i = 0; i < consoleParticipants.length; i++) { - participants.add(consoleParticipants[i]); + for (IConsolePageParticipant consoleParticipant : consoleParticipants) { + participants.add(consoleParticipant); } fConsoleToPageParticipants.put(console, participants); for (IConsolePageParticipant iConsolePageParticipant : participants) { @@ -398,13 +398,11 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL public void consolesAdded(final IConsole[] consoles) { if (isAvailable()) { Runnable r = () -> { - for (int i = 0; i < consoles.length; i++) { + for (IConsole console : consoles) { if (isAvailable()) { - IConsole console = consoles[i]; // ensure it's still registered since this is done asynchronously IConsole[] allConsoles = getConsoleManager().getConsoles(); - for (int j = 0; j < allConsoles.length; j++) { - IConsole registered = allConsoles[j]; + for (IConsole registered : allConsoles) { if (registered.equals(console)) { ConsoleWorkbenchPart part = new ConsoleWorkbenchPart(console, getSite()); fConsoleToPart.put(console, part); @@ -413,7 +411,6 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL break; } } - } } }; @@ -425,9 +422,8 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL public void consolesRemoved(final IConsole[] consoles) { if (isAvailable()) { Runnable r = () -> { - for (int i = 0; i < consoles.length; i++) { + for (IConsole console : consoles) { if (isAvailable()) { - IConsole console = consoles[i]; fStack.remove(console); ConsoleWorkbenchPart part = fConsoleToPart.get(console); if (part != null) { diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/OpenConsoleAction.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/OpenConsoleAction.java index 6559f6601..1a25fddf3 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/OpenConsoleAction.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/OpenConsoleAction.java @@ -101,8 +101,7 @@ public class OpenConsoleAction extends Action implements IMenuCreator { fMenu= new Menu(parent); int accel = 1; - for (int i = 0; i < fFactoryExtensions.length; i++) { - ConsoleFactoryExtension extension = fFactoryExtensions[i]; + for (ConsoleFactoryExtension extension : fFactoryExtensions) { if (!WorkbenchActivityHelper.filterItem(extension) && extension.isEnabled()) { String label = extension.getLabel(); ImageDescriptor image = extension.getImageDescriptor(); diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/PatternMatchListenerExtension.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/PatternMatchListenerExtension.java index 8d226809b..49d598494 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/PatternMatchListenerExtension.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/PatternMatchListenerExtension.java @@ -59,9 +59,8 @@ public class PatternMatchListenerExtension implements IPluginContribution { String flags = flagsElement.replaceAll("Pattern.", ""); //$NON-NLS-1$ //$NON-NLS-2$ String[] tokens = flags.split("\\s\\|\\s"); //$NON-NLS-1$ Class<?> clazz = Class.forName("java.util.regex.Pattern"); //$NON-NLS-1$ - - for (int i = 0; i < tokens.length; i++) { - Field field = clazz.getDeclaredField(tokens[i]); + for (String token : tokens) { + Field field = clazz.getDeclaredField(token); val |= field.getInt(null); } } catch (ClassNotFoundException e) { diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsBuildTab.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsBuildTab.java index 82f689608..a0e96b04a 100644 --- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsBuildTab.java +++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsBuildTab.java @@ -186,8 +186,8 @@ public class ExternalToolsBuildTab extends AbstractLaunchConfigurationTab { } Object[] res = dialog.getResult(); fProjects = new ArrayList<>(res.length); - for (int i = 0; i < res.length; i++) { - fProjects.add((IProject) res[i]); + for (Object re : res) { + fProjects.add((IProject) re); } updateLaunchConfigurationDialog(); } diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsMainTab.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsMainTab.java index 7c050f866..be06daad4 100644 --- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsMainTab.java +++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsMainTab.java @@ -625,8 +625,8 @@ public abstract class ExternalToolsMainTab extends AbstractLaunchConfigurationTa //strip mnemonic (&) String[] strs = controlName.split("&"); //$NON-NLS-1$ StringBuilder stripped = new StringBuilder(); - for (int i = 0; i < strs.length; i++) { - stripped.append(strs[i]); + for (String str : strs) { + stripped.append(str); } control.getAccessible().addAccessibleListener(new ControlAccessibleListener(stripped.toString())); } diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/BuilderUtils.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/BuilderUtils.java index 2605b8587..e0f4d21c8 100644 --- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/BuilderUtils.java +++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/BuilderUtils.java @@ -115,8 +115,7 @@ public class BuilderUtils { IConfigurationElement[] elements = ep.getConfigurationElements(); String sourceType= config.getType().getIdentifier(); String builderType= null; - for (int i= 0; i < elements.length; i++) { - IConfigurationElement element= elements[i]; + for (IConfigurationElement element : elements) { if (element.getName().equals(TAG_CONFIGURATION_MAP) && sourceType.equals(element.getAttribute(TAG_SOURCE_TYPE))) { builderType= element.getAttribute(TAG_BUILDER_TYPE); break; diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/ExternalToolsPlugin.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/ExternalToolsPlugin.java index c081e478d..b5c39c2ab 100644 --- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/ExternalToolsPlugin.java +++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/ExternalToolsPlugin.java @@ -90,9 +90,9 @@ public final class ExternalToolsPlugin extends AbstractUIPlugin implements ILaunch launches[] = manager.getLaunches(); ILaunchConfigurationType configType; ILaunchConfiguration config; - for (int i = 0; i < launches.length; i++) { + for (ILaunch launch : launches) { try { - config = launches[i].getLaunchConfiguration(); + config = launch.getLaunchConfiguration(); if (config == null) { continue; } @@ -101,7 +101,7 @@ public final class ExternalToolsPlugin extends AbstractUIPlugin implements continue; } if (configType.equals(programType)) { - if (!launches[i].isTerminated()) { + if (!launch.isTerminated()) { MessageDialog .openWarning( window.getShell(), diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/BuilderPropertyPage.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/BuilderPropertyPage.java index 7ed6bd20f..e3b96d32d 100644 --- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/BuilderPropertyPage.java +++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/BuilderPropertyPage.java @@ -169,8 +169,7 @@ public final class BuilderPropertyPage extends PropertyPage implements ICheckSta Display.getDefault().asyncExec(() -> { TableItem[] items = viewer.getTable().getItems(); - for (int i = 0; i < items.length; i++) { - TableItem item = items[i]; + for (TableItem item : items) { Object data = item.getData(); if (data == oldConfig) { // Found the movedFrom config in the tree. Replace it @@ -216,9 +215,9 @@ public final class BuilderPropertyPage extends PropertyPage implements ICheckSta } boolean projectNeedsMigration= false; - for (int i = 0; i < commands.length; i++) { + for (ICommand command : commands) { String[] version= new String[] {IExternalToolConstants.EMPTY_STRING}; - ILaunchConfiguration config = BuilderUtils.configFromBuildCommandArgs(project, commands[i].getArguments(), version); + ILaunchConfiguration config = BuilderUtils.configFromBuildCommandArgs(project, command.getArguments(), version); if (BuilderCoreUtils.VERSION_2_1.equals(version[0])) { // Storing the .project file of a project with 2.1 configs, will // edit the file in a way that isn't backwards compatible. @@ -233,19 +232,19 @@ public final class BuilderPropertyPage extends PropertyPage implements ICheckSta } IStatus status = new Status(IStatus.ERROR, ExternalToolsPlugin.PLUGIN_ID, 0, NLS.bind(ExternalToolsUIMessages.BuilderPropertyPage_Exists, new String[]{config.getName()}), null); ErrorDialog.openError(getShell(), ExternalToolsUIMessages.BuilderPropertyPage_errorTitle, - NLS.bind(ExternalToolsUIMessages.BuilderPropertyPage_External_Tool_Builder__0__Not_Added_2, new String[]{config.getName()}), - status); + NLS.bind(ExternalToolsUIMessages.BuilderPropertyPage_External_Tool_Builder__0__Not_Added_2, new String[]{config.getName()}), + status); userHasMadeChanges= true; } else { element= config; } } else { - String builderID = commands[i].getBuilderName(); - if (builderID.equals(ExternalToolBuilder.ID) && commands[i].getArguments().get(BuilderCoreUtils.LAUNCH_CONFIG_HANDLE) != null) { + String builderID = command.getBuilderName(); + if (builderID.equals(ExternalToolBuilder.ID) && command.getArguments().get(BuilderCoreUtils.LAUNCH_CONFIG_HANDLE) != null) { // An invalid external tool entry. - element= new ErrorConfig(commands[i]); + element = new ErrorConfig(command); } else { - element= commands[i]; + element = command; } } if (element != null) { @@ -462,8 +461,7 @@ public final class BuilderPropertyPage extends PropertyPage implements ICheckSta } else { // Replace the config with a working copy TableItem[] items= viewer.getTable().getItems(); - for (int i = 0; i < items.length; i++) { - TableItem item = items[i]; + for (TableItem item : items) { if (item.getData() == configuration) { workingCopy = configuration.getWorkingCopy(); item.setData(workingCopy); @@ -500,8 +498,7 @@ public final class BuilderPropertyPage extends PropertyPage implements ICheckSta for (ILaunchConfigurationType type : toolTypes) { try { ILaunchConfiguration[] configs = manager.getLaunchConfigurations(type); - for (int i = 0; i < configs.length; i++) { - ILaunchConfiguration launchConfiguration = configs[i]; + for (ILaunchConfiguration launchConfiguration : configs) { if (!DebugUITools.isPrivate(launchConfiguration)) { configurations.add(launchConfiguration); } @@ -674,8 +671,7 @@ public final class BuilderPropertyPage extends PropertyPage implements ICheckSta private List<ILaunchConfigurationType> getConfigurationTypes(String category) { ILaunchConfigurationType types[] = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationTypes(); List<ILaunchConfigurationType> externalToolTypes = new ArrayList<>(); - for (int i = 0; i < types.length; i++) { - ILaunchConfigurationType configurationType = types[i]; + for (ILaunchConfigurationType configurationType : types) { if (category.equals(configurationType.getCategory())) { externalToolTypes.add(configurationType); } @@ -812,8 +808,7 @@ public final class BuilderPropertyPage extends PropertyPage implements ICheckSta enableUp = indices[0] != 0; enableDown = indices[indices.length - 1] < max - 1; } - for (int i = 0; i < items.length; i++) { - TableItem item = items[i]; + for (TableItem item : items) { Object data= item.getData(); if (data instanceof ILaunchConfiguration) { ILaunchConfiguration config= (ILaunchConfiguration)data; diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/FileSelectionDialog.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/FileSelectionDialog.java index dc927a575..0305d1e22 100644 --- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/FileSelectionDialog.java +++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/FileSelectionDialog.java @@ -149,8 +149,8 @@ public class FileSelectionDialog extends MessageDialog { //Also try and reset the size of the columns as appropriate TableColumn[] columns = selectionGroup.getListTable().getColumns(); - for (int i = 0; i < columns.length; i++) { - columns[i].pack(); + for (TableColumn column : columns) { + column.pack(); } } }); @@ -170,8 +170,7 @@ public class FileSelectionDialog extends MessageDialog { try { members = ((IContainer) o).members(); List<IResource> accessibleMembers = new ArrayList<>(members.length); - for (int i = 0; i < members.length; i++) { - IResource resource = members[i]; + for (IResource resource : members) { if (resource.isAccessible()) { accessibleMembers.add(resource); } @@ -184,16 +183,14 @@ public class FileSelectionDialog extends MessageDialog { //filter out the desired resource types ArrayList<IResource> results = new ArrayList<>(); - for (int i = 0; i < members.length; i++) { + for (IResource member : members) { //And the test bits with the resource types to see if // they are what we want - if ((members[i].getType() & resourceType) > 0) { - if (members[i].getType() == IResource.FILE - && fPattern != null - && !fPattern.matcher(members[i].getName()).find()) { + if ((member.getType() & resourceType) > 0) { + if (member.getType() == IResource.FILE && fPattern != null && !fPattern.matcher(member.getName()).find()) { continue; } - results.add(members[i]); + results.add(member); } } return results.toArray(); |