Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Vogel2017-02-02 15:57:28 +0000
committerLars Vogel2017-02-03 08:29:10 +0000
commit9e912e29adac8406e1b7a18e20ce5a3028a052a0 (patch)
tree17c0d10112f8abd2dc2f5e672a1d581a161a5b96
parent88a51667c841267a5a7076c649890a356bde0822 (diff)
downloadeclipse.platform.text-9e912e29adac8406e1b7a18e20ce5a3028a052a0.tar.gz
eclipse.platform.text-9e912e29adac8406e1b7a18e20ce5a3028a052a0.tar.xz
eclipse.platform.text-9e912e29adac8406e1b7a18e20ce5a3028a052a0.zip
Bug 493304 - Prefer usage of enhanced for loop in eclipse.platform.text
repo Part 1 for the org.eclipse.jface.text plug-in Change-Id: Ib037e06e3346e9ce50281bbc11b87bcbb962eb56 Signed-off-by: Lars Vogel <Lars.Vogel@vogella.com>
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/contentassist/AbstractControlContentAssistSubjectAdapter.java13
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/HTMLPrinter.java4
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/CompletionProposalPopup2.java4
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContentAssistant2.java15
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContextInformationPopup2.java4
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractInformationControl.java4
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractInformationControlManager.java4
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/BoldStylerProvider.java4
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposalPopup.java8
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java15
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformationPopup.java8
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformationValidator.java4
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/ContentFormatter.java36
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/FormattingContext.java10
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/hyperlink/HyperlinkManager.java9
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/rules/DefaultPartitioner.java4
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/rules/FastPartitioner.java4
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationBarHoverManager.java6
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationPainter.java29
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/CompositeRuler.java13
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/DefaultCharacterPairMatcher.java4
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineChangeHover.java4
22 files changed, 92 insertions, 114 deletions
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/AbstractControlContentAssistSubjectAdapter.java b/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/AbstractControlContentAssistSubjectAdapter.java
index 15666bf78..b5b6d35b2 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/AbstractControlContentAssistSubjectAdapter.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/AbstractControlContentAssistSubjectAdapter.java
@@ -12,7 +12,6 @@ package org.eclipse.jface.contentassist;
import java.util.ArrayList;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Set;
@@ -192,8 +191,8 @@ public abstract class AbstractControlContentAssistSubjectAdapter implements ICon
dump("before traverse", e, verifyEvent); //$NON-NLS-1$
verifyEvent.doit= true;
- for (Iterator<VerifyKeyListener> iter= fVerifyKeyListeners.iterator(); iter.hasNext(); ) {
- iter.next().verifyKey(verifyEvent);
+ for (VerifyKeyListener verifyKeyListener : fVerifyKeyListeners) {
+ verifyKeyListener.verifyKey(verifyEvent);
if (! verifyEvent.doit) {
e.detail= SWT.TRAVERSE_NONE;
e.doit= true;
@@ -208,8 +207,8 @@ public abstract class AbstractControlContentAssistSubjectAdapter implements ICon
break;
case SWT.KeyDown:
- for (Iterator<VerifyKeyListener> iter= fVerifyKeyListeners.iterator(); iter.hasNext(); ) {
- iter.next().verifyKey(verifyEvent);
+ for (VerifyKeyListener verifyKeyListener : fVerifyKeyListeners) {
+ verifyKeyListener.verifyKey(verifyEvent);
if (! verifyEvent.doit) {
e.doit= verifyEvent.doit;
if (DEBUG)
@@ -221,8 +220,8 @@ public abstract class AbstractControlContentAssistSubjectAdapter implements ICon
if (DEBUG)
dump("keyDown OK", e, verifyEvent); //$NON-NLS-1$
- for (Iterator<KeyListener> iter= fKeyListeners.iterator(); iter.hasNext();) {
- iter.next().keyPressed(keyEvent);
+ for (KeyListener keyListener : fKeyListeners) {
+ keyListener.keyPressed(keyEvent);
}
break;
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/HTMLPrinter.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/HTMLPrinter.java
index 5fc2cea8c..57ee85a7f 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/HTMLPrinter.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/HTMLPrinter.java
@@ -200,9 +200,9 @@ public class HTMLPrinter {
return;
StringBuffer styleBuf= new StringBuffer(10 * styles.length);
- for (int i= 0; i < styles.length; i++) {
+ for (String style : styles) {
styleBuf.append(" style=\""); //$NON-NLS-1$
- styleBuf.append(styles[i]);
+ styleBuf.append(style);
styleBuf.append('"');
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/CompletionProposalPopup2.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/CompletionProposalPopup2.java
index 34cb87699..8e39c1391 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/CompletionProposalPopup2.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/CompletionProposalPopup2.java
@@ -845,8 +845,8 @@ class CompletionProposalPopup2 implements IContentAssistListener2 {
if (characters == null)
return false;
- for (int i= 0; i < characters.length; i++) {
- if (c == characters[i])
+ for (char character : characters) {
+ if (c == character)
return true;
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContentAssistant2.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContentAssistant2.java
index 6549c11d5..6741ba96a 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContentAssistant2.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContentAssistant2.java
@@ -12,7 +12,6 @@ package org.eclipse.jface.internal.text.link.contentassist;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -263,9 +262,10 @@ public class ContentAssistant2 implements IContentAssistant, IContentAssistantEx
private boolean contains(char[] characters, char character) {
if (characters != null) {
- for (int i= 0; i < characters.length; i++) {
- if (character == characters[i])
+ for (char c : characters) {
+ if (character == c) {
return true;
+ }
}
}
return false;
@@ -634,9 +634,9 @@ public class ContentAssistant2 implements IContentAssistant, IContentAssistantEx
installKeyListener();
IContentAssistListener2[] listeners= fListeners.clone();
- for (int i= 0; i < listeners.length; i++) {
- if (listeners[i] != null) {
- listeners[i].processEvent(event);
+ for (IContentAssistListener2 listener : listeners) {
+ if (listener != null) {
+ listener.processEvent(event);
if (!event.doit)
return;
}
@@ -1523,8 +1523,7 @@ public class ContentAssistant2 implements IContentAssistant, IContentAssistantEx
*/
public void fireProposalChosen(ICompletionProposal proposal) {
List<IProposalListener> list= new ArrayList<>(fProposalListeners);
- for (Iterator<IProposalListener> it= list.iterator(); it.hasNext();) {
- IProposalListener listener= it.next();
+ for (IProposalListener listener : list) {
listener.proposalChosen(proposal);
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContextInformationPopup2.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContextInformationPopup2.java
index ce022e648..0632c2d8f 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContextInformationPopup2.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContextInformationPopup2.java
@@ -395,8 +395,8 @@ class ContextInformationPopup2 implements IContentAssistListener2 {
TableItem item;
IContextInformation t;
- for (int i= 0; i < contexts.length; i++) {
- t= contexts[i];
+ for (IContextInformation context : contexts) {
+ t= context;
item= new TableItem(fContextSelectorTable, SWT.NULL);
if (t.getImage() != null)
item.setImage(t.getImage());
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractInformationControl.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractInformationControl.java
index b3c410fc0..320932d27 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractInformationControl.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractInformationControl.java
@@ -245,8 +245,8 @@ public abstract class AbstractInformationControl implements IInformationControl,
fStatusLabel.setText(statusFieldText);
FontData[] fontDatas= JFaceResources.getDialogFont().getFontData();
- for (int i= 0; i < fontDatas.length; i++) {
- fontDatas[i].setHeight(fontDatas[i].getHeight() * 9 / 10);
+ for (FontData fontData : fontDatas) {
+ fontData.setHeight(fontData.getHeight() * 9 / 10);
}
fStatusLabelFont= new Font(fStatusLabel.getDisplay(), fontDatas);
fStatusLabel.setFont(fStatusLabelFont);
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractInformationControlManager.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractInformationControlManager.java
index a1af6b22e..9ac42ac02 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractInformationControlManager.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractInformationControlManager.java
@@ -1105,9 +1105,7 @@ abstract public class AbstractInformationControlManager {
Monitor[] monitors = display.getMonitors();
Monitor result = monitors[0];
- for (int idx = 0; idx < monitors.length; idx++) {
- Monitor current = monitors[idx];
-
+ for (Monitor current : monitors) {
Rectangle clientArea = current.getClientArea();
if (clientArea.contains(toFind)) {
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/BoldStylerProvider.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/BoldStylerProvider.java
index 5853d4e14..128170595 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/BoldStylerProvider.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/BoldStylerProvider.java
@@ -81,8 +81,8 @@ public final class BoldStylerProvider {
public Font getBoldFont() {
if (fBoldFont == null) {
FontData[] data= fFont.getFontData();
- for (int i= 0; i < data.length; i++) {
- data[i].setStyle(SWT.BOLD);
+ for (FontData element : data) {
+ element.setStyle(SWT.BOLD);
}
fBoldFont= new Font(fFont.getDevice(), data);
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposalPopup.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposalPopup.java
index 365dc2408..b119ae22d 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposalPopup.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposalPopup.java
@@ -810,8 +810,8 @@ class CompletionProposalPopup implements IContentAssistListener {
Font font= fMessageText.getFont();
Display display= fProposalShell.getDisplay();
FontData[] fontDatas= font.getFontData();
- for (int i= 0; i < fontDatas.length; i++)
- fontDatas[i].setHeight(fontDatas[i].getHeight() * 9 / 10);
+ for (FontData fontData : fontDatas)
+ fontData.setHeight(fontData.getHeight() * 9 / 10);
fMessageTextFont= new Font(display, fontDatas);
}
fMessageText.setFont(fMessageTextFont);
@@ -1446,8 +1446,8 @@ class CompletionProposalPopup implements IContentAssistListener {
if (characters == null)
return false;
- for (int i= 0; i < characters.length; i++) {
- if (c == characters[i])
+ for (char character : characters) {
+ if (c == character)
return true;
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java
index 84eee07dc..b22164821 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java
@@ -298,9 +298,10 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt
private boolean contains(char[] characters, char character) {
if (characters != null) {
- for (int i= 0; i < characters.length; i++) {
- if (character == characters[i])
+ for (char c : characters) {
+ if (character == c) {
return true;
+ }
}
}
return false;
@@ -768,9 +769,7 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt
Monitor[] monitors = toSearch.getMonitors();
Monitor result = monitors[0];
- for (int idx = 0; idx < monitors.length; idx++) {
- Monitor current = monitors[idx];
-
+ for (Monitor current : monitors) {
Rectangle clientArea = current.getClientArea();
if (clientArea.contains(toFind)) {
@@ -822,9 +821,9 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt
installKeyListener();
IContentAssistListener[] listeners= fListeners.clone();
- for (int i= 0; i < listeners.length; i++) {
- if (listeners[i] != null) {
- listeners[i].processEvent(event);
+ for (IContentAssistListener listener : listeners) {
+ if (listener != null) {
+ listener.processEvent(event);
if (!event.doit)
return;
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformationPopup.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformationPopup.java
index 1e51617a7..f733d6dad 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformationPopup.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformationPopup.java
@@ -10,7 +10,6 @@
*******************************************************************************/
package org.eclipse.jface.text.contentassist;
-import java.util.Iterator;
import java.util.Stack;
import org.eclipse.swt.SWT;
@@ -218,8 +217,7 @@ class ContextInformationPopup implements IContentAssistListener {
}
// also check all other contexts
- for (Iterator<ContextFrame> it= fContextFrameStack.iterator(); it.hasNext(); ) {
- ContextFrame stackFrame= it.next();
+ for (ContextFrame stackFrame : fContextFrameStack) {
if (stackFrame.equals(frame)) {
validateContextInformation();
return;
@@ -642,8 +640,8 @@ class ContextInformationPopup implements IContentAssistListener {
TableItem item;
IContextInformation t;
- for (int i= 0; i < contexts.length; i++) {
- t= contexts[i];
+ for (IContextInformation context : contexts) {
+ t= context;
item= new TableItem(fContextSelectorTable, SWT.NULL);
if (t.getImage() != null)
item.setImage(t.getImage());
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformationValidator.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformationValidator.java
index 694018a8a..c7f78bf0f 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformationValidator.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformationValidator.java
@@ -49,8 +49,8 @@ public final class ContextInformationValidator implements IContextInformationVal
public boolean isContextInformationValid(int offset) {
IContextInformation[] infos= fProcessor.computeContextInformation(fViewer, offset);
if (infos != null && infos.length > 0) {
- for (int i= 0; i < infos.length; i++)
- if (fContextInformation.equals(infos[i]))
+ for (IContextInformation info : infos)
+ if (fContextInformation.equals(info))
return true;
}
return false;
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/ContentFormatter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/ContentFormatter.java
index fd0d9b8dd..de1b4c93d 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/ContentFormatter.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/ContentFormatter.java
@@ -453,8 +453,8 @@ public class ContentFormatter implements IContentFormatter {
* @param indentation the initial indentation
*/
private void start(TypedPosition[] regions, String indentation) {
- for (int i= 0; i < regions.length; i++) {
- IFormattingStrategy s= getFormattingStrategy(regions[i].getType());
+ for (TypedPosition region : regions) {
+ IFormattingStrategy s= getFormattingStrategy(region.getType());
if (s != null)
s.formatterStarts(indentation);
}
@@ -468,10 +468,10 @@ public class ContentFormatter implements IContentFormatter {
* @since 3.0
*/
private void format(TypedPosition[] ranges) {
- for (int i= 0; i < ranges.length; i++) {
- IFormattingStrategy s= getFormattingStrategy(ranges[i].getType());
+ for (TypedPosition range : ranges) {
+ IFormattingStrategy s= getFormattingStrategy(range.getType());
if (s != null) {
- format(s, ranges[i]);
+ format(s, range);
}
}
}
@@ -525,8 +525,8 @@ public class ContentFormatter implements IContentFormatter {
* @param regions the partitioning of the document which has been formatted
*/
private void stop(TypedPosition[] regions) {
- for (int i= 0; i < regions.length; i++) {
- IFormattingStrategy s= getFormattingStrategy(regions[i].getType());
+ for (TypedPosition region : regions) {
+ IFormattingStrategy s= getFormattingStrategy(region.getType());
if (s != null)
s.formatterStops();
}
@@ -585,17 +585,18 @@ public class ContentFormatter implements IContentFormatter {
*/
private boolean ignoreCategory(String category) {
- if (PARTITIONING.equals(category))
+ if (PARTITIONING.equals(category)) {
return true;
+ }
String[] categories= getPartitionManagingCategories();
if (categories != null) {
- for (int i= 0; i < categories.length; i++) {
- if (categories[i].equals(category))
+ for (String cat : categories) {
+ if (cat.equals(category)) {
return true;
+ }
}
}
-
return false;
}
@@ -611,25 +612,24 @@ public class ContentFormatter implements IContentFormatter {
String[] categories= fDocument.getPositionCategories();
if (categories != null) {
- for (int i= 0; i < categories.length; i++) {
+ for (String cat : categories) {
- if (ignoreCategory(categories[i]))
+ if (ignoreCategory(cat))
continue;
try {
- Position[] positions= fDocument.getPositions(categories[i]);
+ Position[] positions= fDocument.getPositions(cat);
- for (int j= 0; j < positions.length; j++) {
+ for (Position p : positions) {
- Position p= positions[j];
if (p.overlapsWith(offset, length)) {
if (offset < p.getOffset())
- fOverlappingPositionReferences.add(new PositionReference(p, true, categories[i]));
+ fOverlappingPositionReferences.add(new PositionReference(p, true, cat));
if (p.getOffset() + p.getLength() < offset + length)
- fOverlappingPositionReferences.add(new PositionReference(p, false, categories[i]));
+ fOverlappingPositionReferences.add(new PositionReference(p, false, cat));
}
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/FormattingContext.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/FormattingContext.java
index adce03929..e5810cf84 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/FormattingContext.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/FormattingContext.java
@@ -80,10 +80,10 @@ public class FormattingContext implements IFormattingContext {
String result= null;
String preference= null;
- for (int index= 0; index < preferences.length; index++) {
+ for (String pref : preferences) {
- preference= preferences[index];
- result= (String)map.get(preference);
+ preference= pref;
+ result= (String) map.get(preference);
if (result != null) {
@@ -119,9 +119,9 @@ public class FormattingContext implements IFormattingContext {
final String[] preferences= getPreferenceKeys();
String preference= null;
- for (int index= 0; index < preferences.length; index++) {
+ for (String pref : preferences) {
- preference= preferences[index];
+ preference= pref;
if (isBooleanPreference(preference)) {
map.put(preference, (useDefault ? store.getDefaultBoolean(preference) : store.getBoolean(preference)) ? IPreferenceStore.TRUE : IPreferenceStore.FALSE);
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/hyperlink/HyperlinkManager.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/hyperlink/HyperlinkManager.java
index 9997c3963..bbe9f8ef6 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/hyperlink/HyperlinkManager.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/hyperlink/HyperlinkManager.java
@@ -269,8 +269,7 @@ public class HyperlinkManager implements ITextListener, Listener, KeyListener, M
private IHyperlink[] findHyperlinks(IRegion region) {
List<IHyperlink> allHyperlinks= new ArrayList<>(fHyperlinkDetectors.length * 2);
synchronized (fHyperlinkDetectors) {
- for (int i= 0, length= fHyperlinkDetectors.length; i < length; i++) {
- IHyperlinkDetector detector= fHyperlinkDetectors[i];
+ for (IHyperlinkDetector detector : fHyperlinkDetectors) {
if (detector == null)
continue;
@@ -468,9 +467,9 @@ public class HyperlinkManager implements ITextListener, Listener, KeyListener, M
return true;
synchronized (fHyperlinkDetectors) {
- for (int i= 0; i < fHyperlinkDetectors.length; i++) {
- if (fHyperlinkDetectors[i] instanceof IHyperlinkDetectorExtension2) {
- if (stateMask == ((IHyperlinkDetectorExtension2)fHyperlinkDetectors[i]).getStateMask())
+ for (IHyperlinkDetector fHyperlinkDetector : fHyperlinkDetectors) {
+ if (fHyperlinkDetector instanceof IHyperlinkDetectorExtension2) {
+ if (stateMask == ((IHyperlinkDetectorExtension2)fHyperlinkDetector).getStateMask())
return true;
}
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/DefaultPartitioner.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/DefaultPartitioner.java
index 7c8cdb1e2..2df1e61fb 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/DefaultPartitioner.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/DefaultPartitioner.java
@@ -487,8 +487,8 @@ public class DefaultPartitioner implements IDocumentPartitioner, IDocumentPartit
*/
protected boolean isSupportedContentType(String contentType) {
if (contentType != null) {
- for (int i= 0; i < fLegalContentTypes.length; i++) {
- if (fLegalContentTypes[i].equals(contentType))
+ for (String fLegalContentType : fLegalContentTypes) {
+ if (fLegalContentType.equals(contentType))
return true;
}
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/FastPartitioner.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/FastPartitioner.java
index b55c2c1c3..48db2a65a 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/FastPartitioner.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/FastPartitioner.java
@@ -544,8 +544,8 @@ public class FastPartitioner implements IDocumentPartitioner, IDocumentPartition
*/
protected boolean isSupportedContentType(String contentType) {
if (contentType != null) {
- for (int i= 0; i < fLegalContentTypes.length; i++) {
- if (fLegalContentTypes[i].equals(contentType))
+ for (String fLegalContentType : fLegalContentTypes) {
+ if (fLegalContentType.equals(contentType))
return true;
}
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationBarHoverManager.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationBarHoverManager.java
index cddb13704..b9689e404 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationBarHoverManager.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationBarHoverManager.java
@@ -472,9 +472,9 @@ public class AnnotationBarHoverManager extends AbstractHoverInformationControlMa
private IRegion findRegionContainingLine(IRegion[] regions, int line) throws BadLocationException {
IDocument document= fSourceViewer.getDocument();
IRegion lineInfo= document.getLineInformation(line);
- for (int i= 0; i < regions.length; i++) {
- if (TextUtilities.overlaps(regions[i], lineInfo))
- return regions[i];
+ for (IRegion region : regions) {
+ if (TextUtilities.overlaps(region, lineInfo))
+ return region;
}
return null;
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationPainter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationPainter.java
index 93a20c2f4..0e2beab73 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationPainter.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationPainter.java
@@ -591,8 +591,7 @@ public class AnnotationPainter implements IPainter, PaintListener, IAnnotationMo
// Remove annotations
Annotation[] removedAnnotations= event.getRemovedAnnotations();
- for (int i= 0, length= removedAnnotations.length; i < length; i++) {
- Annotation annotation= removedAnnotations[i];
+ for (Annotation annotation : removedAnnotations) {
Decoration decoration= highlightedDecorationsMap.remove(annotation);
if (decoration != null) {
Position position= decoration.fPosition;
@@ -615,9 +614,7 @@ public class AnnotationPainter implements IPainter, PaintListener, IAnnotationMo
// Update existing annotations
Annotation[] changedAnnotations= event.getChangedAnnotations();
- for (int i= 0, length= changedAnnotations.length; i < length; i++) {
- Annotation annotation= changedAnnotations[i];
-
+ for (Annotation annotation : changedAnnotations) {
boolean isHighlighting= false;
Decoration decoration= highlightedDecorationsMap.get(annotation);
@@ -888,8 +885,8 @@ public class AnnotationPainter implements IPainter, PaintListener, IAnnotationMo
if (fAnnotationAccess instanceof IAnnotationAccessExtension) {
IAnnotationAccessExtension ext = (IAnnotationAccessExtension) fAnnotationAccess;
Object[] sts = ext.getSupertypes(type);
- for (int i= 0; i < sts.length; i++) {
- strategy= fPaintingStrategyId2PaintingStrategy.get(fAnnotationType2PaintingStrategyId.get(sts[i]));
+ for (Object st : sts) {
+ strategy= fPaintingStrategyId2PaintingStrategy.get(fAnnotationType2PaintingStrategyId.get(st));
if (strategy != null) {
fCachedAnnotationType2PaintingStrategy.put(type, strategy);
return strategy;
@@ -924,8 +921,8 @@ public class AnnotationPainter implements IPainter, PaintListener, IAnnotationMo
IAnnotationAccessExtension extension= (IAnnotationAccessExtension) fAnnotationAccess;
Object[] superTypes= extension.getSupertypes(annotationType);
if (superTypes != null) {
- for (int i= 0; i < superTypes.length; i++) {
- color= fAnnotationType2Color.get(superTypes[i]);
+ for (Object superType : superTypes) {
+ color= fAnnotationType2Color.get(superType);
if (color != null) {
fCachedAnnotationType2Color.put(annotationType, color);
return color;
@@ -992,9 +989,7 @@ public class AnnotationPainter implements IPainter, PaintListener, IAnnotationMo
for (int layer= 0, maxLayer= 1; layer < maxLayer; layer++) {
- for (Iterator<Entry<Annotation, Decoration>> iter= decorations.iterator(); iter.hasNext();) {
- Entry<Annotation, Decoration> entry= iter.next();
-
+ for (Entry<Annotation, Decoration> entry : decorations) {
Annotation a= entry.getKey();
if (a.isMarkedDeleted())
continue;
@@ -1373,9 +1368,7 @@ public class AnnotationPainter implements IPainter, PaintListener, IAnnotationMo
* expensive. One bucket per drawing layer. Use linked lists as addition is cheap here.
*/
ArrayList<LinkedList<Entry<Annotation, Decoration>>> toBeDrawn= new ArrayList<>(10);
- for (Iterator<Entry<Annotation, Decoration>> e = decorations.iterator(); e.hasNext();) {
- Entry<Annotation, Decoration> entry= e.next();
-
+ for (Entry<Annotation, Decoration> entry : decorations) {
Annotation a= entry.getKey();
Decoration pp = entry.getValue();
// prune any annotation that is not drawable or does not need drawing
@@ -1387,10 +1380,8 @@ public class AnnotationPainter implements IPainter, PaintListener, IAnnotationMo
}
}
IDocument document= fSourceViewer.getDocument();
- for (Iterator<LinkedList<Entry<Annotation, Decoration>>> it= toBeDrawn.iterator(); it.hasNext();) {
- LinkedList<Entry<Annotation, Decoration>> layer= it.next();
- for (Iterator<Entry<Annotation, Decoration>> e = layer.iterator(); e.hasNext();) {
- Entry<Annotation, Decoration> entry= e.next();
+ for (LinkedList<Entry<Annotation, Decoration>> layer : toBeDrawn) {
+ for (Entry<Annotation, Decoration> entry : layer) {
Annotation a= entry.getKey();
Decoration pp = entry.getValue();
drawDecoration(pp, gc, a, clippingRegion, document);
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/CompositeRuler.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/CompositeRuler.java
index 4b62c5870..d864a8a9d 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/CompositeRuler.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/CompositeRuler.java
@@ -87,8 +87,8 @@ public class CompositeRuler implements IVerticalRuler, IVerticalRulerExtension,
protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) {
Control[] children= composite.getChildren();
Point size= new Point(0, 0);
- for (int i= 0; i < children.length; i++) {
- Point s= children[i].computeSize(SWT.DEFAULT, SWT.DEFAULT, flushCache);
+ for (Control element : children) {
+ Point s= element.computeSize(SWT.DEFAULT, SWT.DEFAULT, flushCache);
size.x += s.x;
size.y= Math.max(size.y, s.y);
}
@@ -787,8 +787,7 @@ public class CompositeRuler implements IVerticalRuler, IVerticalRulerExtension,
*/
public void fireAnnotationSelected(VerticalRulerEvent event) {
// forward to listeners
- for (Iterator<IVerticalRulerListener> it= fAnnotationListeners.iterator(); it.hasNext();) {
- IVerticalRulerListener listener= it.next();
+ for (IVerticalRulerListener listener : fAnnotationListeners) {
listener.annotationSelected(event);
}
}
@@ -803,8 +802,7 @@ public class CompositeRuler implements IVerticalRuler, IVerticalRulerExtension,
*/
public void fireAnnotationDefaultSelected(VerticalRulerEvent event) {
// forward to listeners
- for (Iterator<IVerticalRulerListener> it= fAnnotationListeners.iterator(); it.hasNext();) {
- IVerticalRulerListener listener= it.next();
+ for (IVerticalRulerListener listener : fAnnotationListeners) {
listener.annotationDefaultSelected(event);
}
}
@@ -820,8 +818,7 @@ public class CompositeRuler implements IVerticalRuler, IVerticalRulerExtension,
*/
public void fireAnnotationContextMenuAboutToShow(VerticalRulerEvent event, Menu menu) {
// forward to listeners
- for (Iterator<IVerticalRulerListener> it= fAnnotationListeners.iterator(); it.hasNext();) {
- IVerticalRulerListener listener= it.next();
+ for (IVerticalRulerListener listener : fAnnotationListeners) {
listener.annotationContextMenuAboutToShow(event, menu);
}
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/DefaultCharacterPairMatcher.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/DefaultCharacterPairMatcher.java
index 51f3d8310..5f53a5293 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/DefaultCharacterPairMatcher.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/DefaultCharacterPairMatcher.java
@@ -588,8 +588,8 @@ public class DefaultCharacterPairMatcher implements ICharacterPairMatcher, IChar
*/
public boolean contains(char c) {
char[] pairs= fPairs;
- for (int i= 0, n= pairs.length; i < n; i++) {
- if (c == pairs[i])
+ for (char pair : pairs) {
+ if (c == pair)
return true;
}
return false;
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineChangeHover.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineChangeHover.java
index fe1912ae8..13a676b41 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineChangeHover.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineChangeHover.java
@@ -10,7 +10,6 @@
*******************************************************************************/
package org.eclipse.jface.text.source;
-import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
@@ -117,8 +116,7 @@ public class LineChangeHover implements IAnnotationHover, IAnnotationHoverExtens
*/
StringBuffer text = new StringBuffer();
int added= 0;
- for (Iterator<? extends ILineDiffInfo> it= diffInfos.iterator(); it.hasNext();) {
- ILineDiffInfo info= it.next();
+ for (ILineDiffInfo info : diffInfos) {
String[] original= info.getOriginalText();
int type= info.getChangeType();
int i= 0;

Back to the top