Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Hammer2019-11-16 14:42:20 +0000
committerKarsten Thoms2019-12-10 15:37:42 +0000
commit15250ab164378b2c5caebfc520885b29863ca5fd (patch)
treea745828e70c5a9fe22d1eb9b91de2f13b9296189
parentc048e3fe4c50cc1d187ab84dc299ca273e2fd738 (diff)
downloadeclipse.platform.text-15250ab164378b2c5caebfc520885b29863ca5fd.tar.gz
eclipse.platform.text-15250ab164378b2c5caebfc520885b29863ca5fd.tar.xz
eclipse.platform.text-15250ab164378b2c5caebfc520885b29863ca5fd.zip
Use jdk 5 for-each loop
Replace simple uses of Iterator with a corresponding for-loop. Also add missing braces on loops as necessary. Change-Id: Ic1786fe30ea297b4686015c1ac5b909f92a528a7 Signed-off-by: Carsten Hammer <carsten.hammer@t-online.de>
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewer.java19
-rw-r--r--org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/EditorAnnotationManager.java18
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/ResourceToItemsMapper.java7
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/SearchDialog.java3
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/templates/ContributionTemplateStore.java5
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/AccessibilityPreferencePage.java4
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/QuickDiffConfigurationBlock.java5
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SelectResourcesBlock.java38
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SpellingConfigurationBlock.java10
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/AnnotationColumn.java3
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/PropertyEventDispatcher.java13
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditor.java5
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractMarkerAnnotationModel.java7
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationTypeLookup.java4
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ChainedPreferenceStore.java7
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerUtilities.java7
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ResourceMarkerAnnotationModel.java4
17 files changed, 60 insertions, 99 deletions
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewer.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewer.java
index 099931c48..bc84985a2 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewer.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewer.java
@@ -2633,8 +2633,7 @@ public class TextViewer extends Viewer implements
List<ISelectionChangedListener> listeners= fPostSelectionChangedListeners;
if (listeners != null) {
listeners= new ArrayList<>(listeners);
- for (int i= 0; i < listeners.size(); i++) {
- ISelectionChangedListener l= listeners.get(i);
+ for (ISelectionChangedListener l : listeners) {
l.selectionChanged(event);
}
}
@@ -2704,8 +2703,7 @@ public class TextViewer extends Viewer implements
event= ((SlaveDocumentEvent) event).getMasterEvent();
TextEvent e= new TextEvent(cmd.start, cmd.length, cmd.text, cmd.preservedText, event, redraws());
- for (int i= 0; i < textListeners.size(); i++) {
- ITextListener l= textListeners.get(i);
+ for (ITextListener l : textListeners) {
l.textChanged(e);
}
}
@@ -2747,8 +2745,7 @@ public class TextViewer extends Viewer implements
protected void fireInputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) {
List<ITextInputListener> listener= fTextInputListeners;
if (listener != null) {
- for (int i= 0; i < listener.size(); i++) {
- ITextInputListener l= listener.get(i);
+ for (ITextInputListener l : listener) {
l.inputDocumentAboutToBeChanged(oldInput, newInput);
}
}
@@ -2764,8 +2761,7 @@ public class TextViewer extends Viewer implements
protected void fireInputDocumentChanged(IDocument oldInput, IDocument newInput) {
List<ITextInputListener> listener= fTextInputListeners;
if (listener != null) {
- for (int i= 0; i < listener.size(); i++) {
- ITextInputListener l= listener.get(i);
+ for (ITextInputListener l : listener) {
l.inputDocumentChanged(oldInput, newInput);
}
}
@@ -2982,8 +2978,7 @@ public class TextViewer extends Viewer implements
int topPixel= fTextWidget.getTopPixel();
if (topPixel >= 0 && topPixel != fLastTopPixel) {
if (fViewportListeners != null) {
- for (int i= 0; i < fViewportListeners.size(); i++) {
- IViewportListener l= fViewportListeners.get(i);
+ for (IViewportListener l : fViewportListeners) {
l.viewportChanged(topPixel);
}
}
@@ -4751,9 +4746,7 @@ public class TextViewer extends Viewer implements
* and let them apply their presentation.
*/
if (fTextPresentationListeners != null) {
- ArrayList<ITextPresentationListener> listeners= new ArrayList<>(fTextPresentationListeners);
- for (int i= 0, size= listeners.size(); i < size; i++) {
- ITextPresentationListener listener= listeners.get(i);
+ for (ITextPresentationListener listener : new ArrayList<>(fTextPresentationListeners)) {
listener.applyTextPresentation(presentation);
}
}
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/EditorAnnotationManager.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/EditorAnnotationManager.java
index 4647b7cc4..1d1ae961d 100644
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/EditorAnnotationManager.java
+++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/EditorAnnotationManager.java
@@ -74,8 +74,8 @@ public class EditorAnnotationManager implements ISearchResultListener {
if (fHighlighter != null)
fHighlighter.dispose();
- for (int i= 0; i < fResults.size(); i++) {
- fResults.get(i).removeListener(this);
+ for (AbstractTextSearchResult result : fResults) {
+ result.removeListener(this);
}
fResults.clear();
}
@@ -88,21 +88,20 @@ public class EditorAnnotationManager implements ISearchResultListener {
fHighlighter= null;
}
- for (int i= 0; i < fResults.size(); i++) {
- AbstractTextSearchResult curr= fResults.get(i);
+ for (AbstractTextSearchResult curr : fResults) {
addAnnotations(curr);
}
}
public synchronized void setSearchResults(List<AbstractTextSearchResult> results) {
removeAllAnnotations();
- for (int i= 0; i < fResults.size(); i++) {
- fResults.get(i).removeListener(this);
+ for (AbstractTextSearchResult result : fResults) {
+ result.removeListener(this);
}
fResults.clear();
- for (int i= 0; i < results.size(); i++) {
- addSearchResult(results.get(i));
+ for (AbstractTextSearchResult result : results) {
+ addSearchResult(result);
}
}
@@ -231,8 +230,7 @@ public class EditorAnnotationManager implements ISearchResultListener {
private void removeAnnotations(AbstractTextSearchResult result) {
removeAllAnnotations();
- for (int i= 0; i < fResults.size(); i++) {
- AbstractTextSearchResult curr= fResults.get(i);
+ for (AbstractTextSearchResult curr : fResults) {
if (curr != result) {
addAnnotations(curr);
}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/ResourceToItemsMapper.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/ResourceToItemsMapper.java
index 13886b032..3c5605bca 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/ResourceToItemsMapper.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/ResourceToItemsMapper.java
@@ -57,6 +57,7 @@ class ResourceToItemsMapper {
* Must be called from the UI thread.
* @param changedResource changed resources
*/
+ @SuppressWarnings("unchecked")
public void resourceChanged(IResource changedResource) {
Object obj= fResourceToItem.get(changedResource);
if (obj == null) {
@@ -64,10 +65,8 @@ class ResourceToItemsMapper {
} else if (obj instanceof Item) {
updateItem((Item) obj);
} else { // List of Items
- @SuppressWarnings("unchecked")
- List<Item> list= (List<Item>) obj;
- for (int k= 0; k < list.size(); k++) {
- updateItem(list.get(k));
+ for (Item element : (List<Item>) obj) {
+ updateItem(element);
}
}
}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchDialog.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchDialog.java
index cc996bbd7..4e388408d 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchDialog.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchDialog.java
@@ -813,8 +813,7 @@ public class SearchDialog extends ExtendedDialogWindow implements ISearchPageCon
@Override
public boolean close() {
- for (int i= 0; i < fDescriptors.size(); i++) {
- SearchPageDescriptor desc= fDescriptors.get(i);
+ for (SearchPageDescriptor desc : fDescriptors) {
desc.dispose();
}
return super.close();
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/templates/ContributionTemplateStore.java b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/templates/ContributionTemplateStore.java
index b5b6e8006..1c7d89802 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/templates/ContributionTemplateStore.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/templates/ContributionTemplateStore.java
@@ -20,7 +20,6 @@ import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Iterator;
import java.util.PropertyResourceBundle;
import java.util.ResourceBundle;
@@ -109,9 +108,7 @@ public class ContributionTemplateStore extends TemplateStore {
@Override
protected void loadContributedTemplates() throws IOException {
IConfigurationElement[] extensions= getTemplateExtensions();
- Collection<TemplatePersistenceData> contributed= readContributedTemplates(extensions);
- for (Iterator<TemplatePersistenceData> it= contributed.iterator(); it.hasNext();) {
- TemplatePersistenceData data= it.next();
+ for (TemplatePersistenceData data : readContributedTemplates(extensions)) {
internalAdd(data);
}
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/AccessibilityPreferencePage.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/AccessibilityPreferencePage.java
index af1588746..deb90eef6 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/AccessibilityPreferencePage.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/AccessibilityPreferencePage.java
@@ -15,7 +15,6 @@ package org.eclipse.ui.internal.editors.text;
import java.util.ArrayList;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.Set;
import org.eclipse.swt.SWT;
@@ -464,8 +463,7 @@ public class AccessibilityPreferencePage extends PreferencePage implements IWork
initializeFields();
- for (Iterator<SelectionListener> iterator= fMasterSlaveListeners.iterator(); iterator.hasNext();) {
- SelectionListener listener= iterator.next();
+ for (SelectionListener listener : fMasterSlaveListeners) {
listener.widgetSelected(null);
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/QuickDiffConfigurationBlock.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/QuickDiffConfigurationBlock.java
index 83ab9a36b..28ad62179 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/QuickDiffConfigurationBlock.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/QuickDiffConfigurationBlock.java
@@ -17,7 +17,6 @@ package org.eclipse.ui.internal.editors.text;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
-import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -161,10 +160,8 @@ class QuickDiffConfigurationBlock implements IPreferenceConfigurationBlock {
}
private String[][] createQuickDiffReferenceListModel() {
- List<ReferenceProviderDescriptor> descriptors= new QuickDiff().getReferenceProviderDescriptors();
ArrayList<String[]> listModelItems= new ArrayList<>();
- for (Iterator<ReferenceProviderDescriptor> it= descriptors.iterator(); it.hasNext();) {
- ReferenceProviderDescriptor descriptor= it.next();
+ for (ReferenceProviderDescriptor descriptor : new QuickDiff().getReferenceProviderDescriptors()) {
String label= LegacyActionTools.removeMnemonics(descriptor.getLabel());
listModelItems.add(new String[] { descriptor.getId(), label });
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SelectResourcesBlock.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SelectResourcesBlock.java
index 8a757b557..972bd39b8 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SelectResourcesBlock.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SelectResourcesBlock.java
@@ -152,8 +152,7 @@ class SelectResourcesBlock implements ICheckStateListener, ISelectionChangedList
* @param elements the elements
*/
private void checkNewTreeElements(Object[] elements) {
- for (int i= 0; i < elements.length; ++i) {
- Object currentElement= elements[i];
+ for (Object currentElement : elements) {
boolean checked= checkedStateStore.containsKey(currentElement);
treeViewer.setChecked(currentElement, checked);
treeViewer.setGrayed(currentElement, checked && !whiteCheckedTreeItems.contains(currentElement));
@@ -277,9 +276,8 @@ class SelectResourcesBlock implements ICheckStateListener, ISelectionChangedList
// treeElement
// must remain gray-checked as well. Only ask expanded nodes
if (expandedTreeNodes.contains(treeElement)) {
- Object[] children= treeContentProvider.getChildren(treeElement);
- for (int i= 0; i < children.length; ++i) {
- if (checkedStateStore.containsKey(children[i]))
+ for (Object element : treeContentProvider.getChildren(treeElement)) {
+ if (checkedStateStore.containsKey(element))
return true;
}
}
@@ -306,10 +304,8 @@ class SelectResourcesBlock implements ICheckStateListener, ISelectionChangedList
if (whiteCheckedTreeItems.contains(element)) {
//If this is the first expansion and this is a white
// checked node then check the children
- Object[] children= treeContentProvider.getChildren(element);
- for (int i= 0; i < children.length; ++i) {
- if (!whiteCheckedTreeItems.contains(children[i])) {
- Object child= children[i];
+ for (Object child : treeContentProvider.getChildren(element)) {
+ if (!whiteCheckedTreeItems.contains(child)) {
setWhiteChecked(child, true);
treeViewer.setChecked(child, true);
checkedStateStore.put(child, new ArrayList<>());
@@ -375,9 +371,8 @@ class SelectResourcesBlock implements ICheckStateListener, ISelectionChangedList
if (listChildren == null)
return;
result.addAll(listChildren);
- Object[] children= treeContentProvider.getChildren(treeElement);
- for (int i= 0; i < children.length; ++i) {
- findAllWhiteCheckedItems(children[i], result);
+ for (Object element : treeContentProvider.getChildren(treeElement)) {
+ findAllWhiteCheckedItems(element, result);
}
}
}
@@ -391,10 +386,9 @@ class SelectResourcesBlock implements ICheckStateListener, ISelectionChangedList
* @throws InterruptedException in case of interruption
*/
private void getAllCheckedListItems(IElementFilter filter) throws InterruptedException {
- //Iterate through the children of the root as the root is not in the store
- Object[] children= treeContentProvider.getChildren(root);
- for (int i= 0; i < children.length; ++i) {
- findAllSelectedListElements(children[i], null, whiteCheckedTreeItems.contains(children[i]), filter);
+ //Loop through the children of the root as the root is not in the store
+ for (Object element : treeContentProvider.getChildren(root)) {
+ findAllSelectedListElements(element, null, whiteCheckedTreeItems.contains(element), filter);
}
}
@@ -441,11 +435,10 @@ class SelectResourcesBlock implements ICheckStateListener, ISelectionChangedList
List<Object> result= new ArrayList<>();
- //Iterate through the children of the root as the root is not in the
+ //Loop through the children of the root as the root is not in the
// store
- Object[] children= treeContentProvider.getChildren(root);
- for (int i= 0; i < children.length; ++i) {
- findAllWhiteCheckedItems(children[i], result);
+ for (Object element : treeContentProvider.getChildren(root)) {
+ findAllWhiteCheckedItems(element, result);
}
return result;
@@ -736,9 +729,8 @@ class SelectResourcesBlock implements ICheckStateListener, ISelectionChangedList
// now logically check/uncheck all children as well if it has been
// expanded
if (expandedTreeNodes.contains(treeElement)) {
- Object[] children= treeContentProvider.getChildren(treeElement);
- for (int i= 0; i < children.length; ++i) {
- setTreeChecked(children[i], state);
+ for (Object element : treeContentProvider.getChildren(treeElement)) {
+ setTreeChecked(element, state);
}
}
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SpellingConfigurationBlock.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SpellingConfigurationBlock.java
index 7f886cc47..d474ec533 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SpellingConfigurationBlock.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SpellingConfigurationBlock.java
@@ -15,7 +15,6 @@ package org.eclipse.ui.internal.editors.text;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.Map;
import org.eclipse.swt.SWT;
@@ -521,8 +520,7 @@ class SpellingConfigurationBlock implements IPreferenceConfigurationBlock {
@Override
public void performOk() {
- for (Iterator<ISpellingPreferenceBlock> it= fProviderPreferences.values().iterator(); it.hasNext();) {
- final ISpellingPreferenceBlock block= it.next();
+ for (ISpellingPreferenceBlock block : fProviderPreferences.values()) {
ISafeRunnable runnable= new ISafeRunnable() {
@Override
public void run() throws Exception {
@@ -539,8 +537,7 @@ class SpellingConfigurationBlock implements IPreferenceConfigurationBlock {
@Override
public void performDefaults() {
restoreFromPreferences();
- for (Iterator<ISpellingPreferenceBlock> it= fProviderPreferences.values().iterator(); it.hasNext();) {
- final ISpellingPreferenceBlock block= it.next();
+ for (ISpellingPreferenceBlock block : fProviderPreferences.values()) {
ISafeRunnable runnable= new ISafeRunnable() {
@Override
public void run() throws Exception {
@@ -556,8 +553,7 @@ class SpellingConfigurationBlock implements IPreferenceConfigurationBlock {
@Override
public void dispose() {
- for (Iterator<ISpellingPreferenceBlock> it= fProviderPreferences.values().iterator(); it.hasNext();) {
- final ISpellingPreferenceBlock block= it.next();
+ for (ISpellingPreferenceBlock block : fProviderPreferences.values()) {
ISafeRunnable runnable= new ISafeRunnable() {
@Override
public void run() throws Exception {
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/AnnotationColumn.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/AnnotationColumn.java
index 179d795b1..ba70bcc94 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/AnnotationColumn.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/AnnotationColumn.java
@@ -117,8 +117,7 @@ public class AnnotationColumn extends AbstractContributedRulerColumn implements
if (store != null && fDelegate instanceof AnnotationRulerColumn) {
final AnnotationRulerColumn column= (AnnotationRulerColumn) fDelegate;
// initial set up
- for (Iterator<AnnotationPreference> iter2= fAnnotationPreferences.getAnnotationPreferences().iterator(); iter2.hasNext();) {
- AnnotationPreference preference= iter2.next();
+ for (AnnotationPreference preference : fAnnotationPreferences.getAnnotationPreferences()) {
String key= preference.getVerticalRulerPreferenceKey();
boolean showAnnotation= true;
if (key != null && store.contains(key))
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/PropertyEventDispatcher.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/PropertyEventDispatcher.java
index e422a9aba..856a0eceb 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/PropertyEventDispatcher.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/PropertyEventDispatcher.java
@@ -14,7 +14,6 @@
package org.eclipse.ui.internal.texteditor;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
@@ -45,13 +44,15 @@ public final class PropertyEventDispatcher {
fReverseMap.clear();
fHandlerMap.clear();
}
+
+ @SuppressWarnings("unchecked")
private void firePropertyChange(PropertyChangeEvent event) {
Object value= fHandlerMap.get(event.getProperty());
if (value instanceof IPropertyChangeListener)
((IPropertyChangeListener) value).propertyChange(event);
else if (value instanceof Set)
- for (@SuppressWarnings("unchecked") Iterator<IPropertyChangeListener> it= ((Set<IPropertyChangeListener>) value).iterator(); it.hasNext(); )
- it.next().propertyChange(event);
+ for (IPropertyChangeListener iPropertyChangeListener : ((Set<IPropertyChangeListener>) value))
+ iPropertyChangeListener.propertyChange(event);
}
public void addPropertyChangeListener(String property, IPropertyChangeListener listener) {
Assert.isLegal(property != null);
@@ -88,6 +89,8 @@ public final class PropertyEventDispatcher {
map.remove(key);
}
}
+
+ @SuppressWarnings("unchecked")
public void removePropertyChangeListener(IPropertyChangeListener listener) {
Object value= fReverseMap.get(listener);
if (value == null)
@@ -97,8 +100,8 @@ public final class PropertyEventDispatcher {
multiMapRemove(fHandlerMap, value, listener);
} else if (value instanceof Set) {
fReverseMap.remove(listener);
- for (@SuppressWarnings("unchecked") Iterator<Object> it= ((Set<Object>) value).iterator(); it.hasNext();)
- multiMapRemove(fHandlerMap, it.next(), listener);
+ for (Object object : ((Set<Object>) value))
+ multiMapRemove(fHandlerMap, object, listener);
}
if (fReverseMap.isEmpty())
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditor.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditor.java
index bda3e236b..2134f7142 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditor.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditor.java
@@ -21,7 +21,6 @@ import java.nio.charset.IllegalCharsetNameException;
import java.nio.charset.StandardCharsets;
import java.nio.charset.UnsupportedCharsetException;
import java.util.Iterator;
-import java.util.List;
import com.ibm.icu.text.BreakIterator;
import com.ibm.icu.text.MessageFormat;
@@ -1935,9 +1934,7 @@ public abstract class AbstractDecoratedTextEditor extends StatusTextEditor {
final IColumnSupport support= getAdapter(IColumnSupport.class);
IPreferenceStore store= EditorsUI.getPreferenceStore();
final RulerColumnPreferenceAdapter adapter= new RulerColumnPreferenceAdapter(store, AbstractTextEditor.PREFERENCE_RULER_CONTRIBUTIONS);
- List<RulerColumnDescriptor> descriptors= RulerColumnRegistry.getDefault().getColumnDescriptors();
- for (Iterator<RulerColumnDescriptor> t= descriptors.iterator(); t.hasNext();) {
- final RulerColumnDescriptor descriptor= t.next();
+ for (RulerColumnDescriptor descriptor : RulerColumnRegistry.getDefault().getColumnDescriptors()) {
if (!descriptor.isIncludedInMenu() || !support.isColumnSupported(descriptor))
continue;
final boolean isVisible= support.isColumnVisible(descriptor);
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractMarkerAnnotationModel.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractMarkerAnnotationModel.java
index 83c7f9f3e..552dc491b 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractMarkerAnnotationModel.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractMarkerAnnotationModel.java
@@ -566,8 +566,7 @@ public abstract class AbstractMarkerAnnotationModel extends AnnotationModel impl
boolean isOK= true;
- for (int i= 0; i < fInstantiatedMarkerUpdaters.size(); i++) {
- IMarkerUpdater updater= fInstantiatedMarkerUpdaters.get(i);
+ for (IMarkerUpdater updater : fInstantiatedMarkerUpdaters) {
String markerType= updater.getMarkerType();
if (markerType == null || MarkerUtilities.isMarkerType(marker, markerType)) {
@@ -678,8 +677,8 @@ public abstract class AbstractMarkerAnnotationModel extends AnnotationModel impl
}
// add the markers of deleted positions back to the annotation model
- for (Iterator<Annotation> e= fDeletedAnnotations.iterator(); e.hasNext();) {
- Object o= e.next();
+ for (Annotation annotation : fDeletedAnnotations) {
+ Object o= annotation;
if (o instanceof MarkerAnnotation) {
MarkerAnnotation a= (MarkerAnnotation) o;
Position p= createPositionFromMarker(a.getMarker());
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationTypeLookup.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationTypeLookup.java
index 29f5b8ece..c48902d22 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationTypeLookup.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationTypeLookup.java
@@ -133,9 +133,7 @@ public final class AnnotationTypeLookup {
*/
private void initializeMapping() {
fMapping= new HashMap<>();
- List<AnnotationTypeMapping> mappings= getAnnotationTypeMappings();
- for (int i= 0, l= mappings.size(); i < l; i++) {
- AnnotationTypeMapping atm= mappings.get(i);
+ for (AnnotationTypeMapping atm : getAnnotationTypeMappings()) {
if (atm.isMarkerSeverityDefined()) {
Object severityMap= fMapping.get(atm.fMarkerType);
if (!(severityMap instanceof Map)) {
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ChainedPreferenceStore.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ChainedPreferenceStore.java
index b1b7af194..40d769493 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ChainedPreferenceStore.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ChainedPreferenceStore.java
@@ -114,8 +114,8 @@ public class ChainedPreferenceStore implements IPreferenceStore {
fPreferenceStores= new IPreferenceStore[preferenceStores.length];
System.arraycopy(preferenceStores, 0, fPreferenceStores, 0, preferenceStores.length);
// Create listeners
- for (int i= 0, length= fPreferenceStores.length; i < length; i++) {
- PropertyChangeListener listener= new PropertyChangeListener(fPreferenceStores[i]);
+ for (IPreferenceStore store : fPreferenceStores) {
+ PropertyChangeListener listener= new PropertyChangeListener(store);
fChildListeners.add(listener);
}
}
@@ -395,8 +395,7 @@ public class ChainedPreferenceStore implements IPreferenceStore {
} else {
// event from other than the visible store
boolean eventBeforeVisibleStore= false;
- for (int i= 0, length= fPreferenceStores.length; i < length; i++) {
- IPreferenceStore store= fPreferenceStores[i];
+ for (IPreferenceStore store : fPreferenceStores) {
if (store == visibleStore)
break;
if (store == childPreferenceStore) {
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerUtilities.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerUtilities.java
index 23b6fa8e5..ed5f3a96d 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerUtilities.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerUtilities.java
@@ -105,12 +105,9 @@ public final class MarkerUtilities {
HashMap<String, String[]> allTypes= new HashMap<>();
IExtensionPoint point= Platform.getExtensionRegistry().getExtensionPoint(ResourcesPlugin.PI_RESOURCES, ResourcesPlugin.PT_MARKERS);
if (point != null) {
- IExtension[] extensions = point.getExtensions();
- for (IExtension extension : extensions) {
+ for (IExtension extension : point.getExtensions()) {
ArrayList<String> types= new ArrayList<>();
- IConfigurationElement[] configElements= extension.getConfigurationElements();
- for (int j= 0; j < configElements.length; ++j) {
- IConfigurationElement element= configElements[j];
+ for (IConfigurationElement element : extension.getConfigurationElements()) {
if (element.getName().equalsIgnoreCase("super")) { //$NON-NLS-1$
String type = element.getAttribute("type"); //$NON-NLS-1$
if (type != null) {
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ResourceMarkerAnnotationModel.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ResourceMarkerAnnotationModel.java
index 236cc50e3..b97ada48f 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ResourceMarkerAnnotationModel.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ResourceMarkerAnnotationModel.java
@@ -182,8 +182,8 @@ public class ResourceMarkerAnnotationModel extends AbstractMarkerAnnotationModel
fWorkspace.run(new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
- for (int i= 0; i < markers.length; ++i) {
- markers[i].delete();
+ for (IMarker marker : markers) {
+ marker.delete();
}
}
}, null, IWorkspace.AVOID_UPDATE, null);

Back to the top