Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Vogel2017-02-02 15:57:36 +0000
committerLars Vogel2017-02-03 11:30:18 +0000
commit7ad6da18195945f9459cd803ef24870c5a9b22ac (patch)
tree15dd899276369076a0651ce3317be74cb1d72d72
parent4e55c8746357dbe04de91c0a787a062c2bc77735 (diff)
downloadeclipse.platform.text-7ad6da18195945f9459cd803ef24870c5a9b22ac.tar.gz
eclipse.platform.text-7ad6da18195945f9459cd803ef24870c5a9b22ac.tar.xz
eclipse.platform.text-7ad6da18195945f9459cd803ef24870c5a9b22ac.zip
Bug 493304 - Prefer usage of enhanced for loop in eclipse.platform.text
repo Part 2 for the org.eclipse.jface.text plug-in Change-Id: I183540f8ae58d1448de9607b6c462817a2f670a3 Signed-off-by: Lars Vogel <Lars.Vogel@vogella.com>
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/contentassist/SubjectControlContextInformationValidator.java4
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/TableOwnerDrawSupport.java4
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/RevisionPainter.java28
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/PaintManager.java13
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/TextPresentation.java3
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewer.java13
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/link/LinkedModeUI.java42
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/link/LinkedPositionAnnotations.java6
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/link/TabStopIterator.java7
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/PresentationReconciler.java3
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/Reconciler.java7
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/revisions/Revision.java14
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/revisions/RevisionInformation.java8
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/rules/PatternRule.java8
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/rules/RuleBasedPartitionScanner.java4
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/rules/RuleBasedPartitioner.java12
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/rules/RuleBasedScanner.java4
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/OverviewRuler.java16
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/SourceViewer.java13
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/templates/TemplateCompletionProcessor.java3
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplateReaderWriter.java3
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplateStore.java38
22 files changed, 103 insertions, 150 deletions
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/SubjectControlContextInformationValidator.java b/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/SubjectControlContextInformationValidator.java
index 42974894c..ead480396 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/SubjectControlContextInformationValidator.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/SubjectControlContextInformationValidator.java
@@ -61,8 +61,8 @@ public final class SubjectControlContextInformationValidator implements ISubject
if (fContentAssistSubjectControl != null && fProcessor instanceof ISubjectControlContentAssistProcessor) {
IContextInformation[] infos= ((ISubjectControlContentAssistProcessor)fProcessor).computeContextInformation(fContentAssistSubjectControl, 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;
}
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/TableOwnerDrawSupport.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/TableOwnerDrawSupport.java
index d0cfc19e0..ff05ab978 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/TableOwnerDrawSupport.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/TableOwnerDrawSupport.java
@@ -114,8 +114,8 @@ public class TableOwnerDrawSupport implements Listener {
StyleRange[] ranges= getStyledRanges(item, index);
if (ranges != null) {
- for (int i= 0; i < ranges.length; i++) {
- StyleRange curr= ranges[i];
+ for (StyleRange range : ranges) {
+ StyleRange curr= range;
if (isSelected) {
curr= (StyleRange) curr.clone();
curr.foreground= null;
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/RevisionPainter.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/RevisionPainter.java
index 8c6ee5bfa..af3863ab1 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/RevisionPainter.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/RevisionPainter.java
@@ -14,7 +14,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
@@ -161,8 +160,7 @@ public final class RevisionPainter {
if (info == null)
return;
List<Long> revisions= new ArrayList<>();
- for (Iterator<Revision> it= info.getRevisions().iterator(); it.hasNext();) {
- Revision revision= it.next();
+ for (Revision revision : info.getRevisions()) {
revisions.add(new Long(computeAge(revision)));
}
Collections.sort(revisions);
@@ -694,8 +692,7 @@ public final class RevisionPainter {
// draw change regions
List<RevisionRange> ranges= getRanges(visibleLines);
- for (Iterator<RevisionRange> it= ranges.iterator(); it.hasNext();) {
- RevisionRange region= it.next();
+ for (RevisionRange region : ranges) {
paintRange(region, gc);
}
}
@@ -907,8 +904,7 @@ public final class RevisionPainter {
if (ranges.isEmpty() || line == -1)
return null;
- for (Iterator<RevisionRange> it= ranges.iterator(); it.hasNext();) {
- RevisionRange range= it.next();
+ for (RevisionRange range : ranges) {
if (contains(range, line))
return range;
}
@@ -1078,8 +1074,7 @@ public final class RevisionPainter {
Map<Annotation, Position> added= null;
if (revision != null) {
added= new HashMap<>();
- for (Iterator<RevisionRange> it= revision.getRegions().iterator(); it.hasNext();) {
- RevisionRange range= it.next();
+ for (RevisionRange range : revision.getRegions()) {
try {
IRegion charRegion= toCharRegion(range);
Position position= new Position(charRegion.getOffset(), charRegion.getLength());
@@ -1095,13 +1090,11 @@ public final class RevisionPainter {
IAnnotationModelExtension ext= (IAnnotationModelExtension) fAnnotationModel;
ext.replaceAnnotations(fAnnotations.toArray(new Annotation[fAnnotations.size()]), added);
} else {
- for (Iterator<Annotation> it= fAnnotations.iterator(); it.hasNext();) {
- Annotation annotation= it.next();
+ for (Annotation annotation : fAnnotations) {
fAnnotationModel.removeAnnotation(annotation);
}
if (added != null) {
- for (Iterator<Entry<Annotation, Position>> it= added.entrySet().iterator(); it.hasNext();) {
- Entry<Annotation, Position> entry= it.next();
+ for (Entry<Annotation, Position> entry : added.entrySet()) {
fAnnotationModel.addAnnotation(entry.getKey(), entry.getValue());
}
}
@@ -1156,8 +1149,7 @@ public final class RevisionPainter {
if (fRevisionInfo == null)
return;
- for (Iterator<Revision> it= fRevisionInfo.getRevisions().iterator(); it.hasNext();) {
- Revision revision= it.next();
+ for (Revision revision : fRevisionInfo.getRevisions()) {
if (id.equals(revision.getId())) {
handleRevisionSelected(revision);
return;
@@ -1289,8 +1281,7 @@ public final class RevisionPainter {
ILineRange last= null;
List<RevisionRange> ranges= fFocusRevision.getRegions();
if (up) {
- for (Iterator<RevisionRange> it= ranges.iterator(); it.hasNext();) {
- RevisionRange range= it.next();
+ for (RevisionRange range : ranges) {
ILineRange widgetRange= modelLinesToWidgetLines(range);
if (contains(range, documentHoverLine)) {
nextWidgetRange= last;
@@ -1459,8 +1450,7 @@ public final class RevisionPainter {
if (hasInformation() && (fShowRevision || fShowAuthor)) {
int revisionWidth= 0;
int authorWidth= 0;
- for (Iterator<Revision> it= fRevisionInfo.getRevisions().iterator(); it.hasNext();) {
- Revision revision= it.next();
+ for (Revision revision : fRevisionInfo.getRevisions()) {
revisionWidth= Math.max(revisionWidth, revision.getId().length());
authorWidth= Math.max(authorWidth, revision.getAuthor().length());
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/PaintManager.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/PaintManager.java
index 551bc5b84..fa2a8535e 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/PaintManager.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/PaintManager.java
@@ -12,7 +12,6 @@ package org.eclipse.jface.text;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import org.eclipse.swt.custom.StyledText;
@@ -264,8 +263,8 @@ public final class PaintManager implements KeyListener, MouseListener, ISelectio
fManager= null;
}
- for (Iterator<IPainter> e = fPainters.iterator(); e.hasNext();)
- e.next().dispose();
+ for (IPainter iPainter : fPainters)
+ iPainter.dispose();
fPainters.clear();
fTextViewer.removeTextInputListener(this);
@@ -298,8 +297,8 @@ public final class PaintManager implements KeyListener, MouseListener, ISelectio
* @see IPainter
*/
private void paint(int reason) {
- for (Iterator<IPainter> e = fPainters.iterator(); e.hasNext();)
- e.next().paint(reason);
+ for (IPainter iPainter : fPainters)
+ iPainter.paint(reason);
}
@Override
@@ -350,8 +349,8 @@ public final class PaintManager implements KeyListener, MouseListener, ISelectio
@Override
public void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) {
if (oldInput != null) {
- for (Iterator<IPainter> e= fPainters.iterator(); e.hasNext();)
- e.next().deactivate(false);
+ for (IPainter iPainter : fPainters)
+ iPainter.deactivate(false);
fManager.uninstall(oldInput);
removeListeners();
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/TextPresentation.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/TextPresentation.java
index 1f87a4bfc..e1928e067 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/TextPresentation.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/TextPresentation.java
@@ -407,8 +407,7 @@ public class TextPresentation {
int j= 0;
ArrayList<StyleRange> oldRanges= fRanges;
ArrayList<StyleRange> newRanges= new ArrayList<>(2*ranges.length + oldRanges.size());
- for (int i= 0, n= ranges.length; i < n; i++) {
- StyleRange range= ranges[i];
+ for (StyleRange range : ranges) {
fRanges= oldRanges; // for getFirstIndexAfterWindow(...)
for (int m= getFirstIndexAfterWindow(new Region(range.start, range.length)); j < m; j++)
newRanges.add(oldRanges.get(j));
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 f58949da8..8eb31f9e1 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
@@ -3616,8 +3616,8 @@ public class TextViewer extends Viewer implements
// make iterator robust against adding/removing strategies from within strategies
default:
strategies= new ArrayList<>(strategies);
- for (final Iterator<IAutoEditStrategy> iterator= strategies.iterator(); iterator.hasNext(); )
- iterator.next().customizeDocumentCommand(document, command);
+ for (IAutoEditStrategy iAutoEditStrategy : strategies)
+ iAutoEditStrategy.customizeDocumentCommand(document, command);
break;
}
@@ -4370,8 +4370,7 @@ public class TextViewer extends Viewer implements
// OK - change the document
int decrement= 0;
- for (int i= 0; i < occurrences.length; i++) {
- IRegion r= occurrences[i];
+ for (IRegion r : occurrences) {
d.replace(r.getOffset() - decrement, r.getLength(), ""); //$NON-NLS-1$
decrement += r.getLength();
}
@@ -5516,9 +5515,9 @@ public class TextViewer extends Viewer implements
@Override
public void setHyperlinkDetectors(IHyperlinkDetector[] hyperlinkDetectors, int eventStateMask) {
if (fHyperlinkDetectors != null) {
- for (int i= 0; i < fHyperlinkDetectors.length; i++) {
- if (fHyperlinkDetectors[i] instanceof IHyperlinkDetectorExtension)
- ((IHyperlinkDetectorExtension)fHyperlinkDetectors[i]).dispose();
+ for (IHyperlinkDetector fHyperlinkDetector : fHyperlinkDetectors) {
+ if (fHyperlinkDetector instanceof IHyperlinkDetectorExtension)
+ ((IHyperlinkDetectorExtension)fHyperlinkDetector).dispose();
}
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/link/LinkedModeUI.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/link/LinkedModeUI.java
index 40cf26cd6..d34e191e2 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/link/LinkedModeUI.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/link/LinkedModeUI.java
@@ -14,7 +14,6 @@ package org.eclipse.jface.text.link;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Set;
@@ -339,8 +338,8 @@ public class LinkedModeUI {
public void run() {
if (fIsActive && viewer instanceof IEditingSupportRegistry) {
IEditingSupport[] helpers= ((IEditingSupportRegistry) viewer).getRegisteredSupports();
- for (int i= 0; i < helpers.length; i++) {
- if (helpers[i].ownsFocusShell())
+ for (IEditingSupport helper : helpers) {
+ if (helper.ownsFocusShell())
return;
}
}
@@ -388,8 +387,8 @@ public class LinkedModeUI {
ITextViewer viewer= fCurrentTarget.getViewer();
if (fFramePosition != null && viewer instanceof IEditingSupportRegistry) {
IEditingSupport[] helpers= ((IEditingSupportRegistry) viewer).getRegisteredSupports();
- for (int i= 0; i < helpers.length; i++) {
- if (helpers[i].isOriginator(null, new Region(fFramePosition.getOffset(), fFramePosition.getLength())))
+ for (IEditingSupport helper : helpers) {
+ if (helper.isOriginator(null, new Region(fFramePosition.getOffset(), fFramePosition.getLength())))
return;
}
}
@@ -893,9 +892,9 @@ public class LinkedModeUI {
fCurrentTarget.fAnnotationModel.switchToPosition(fModel, pos);
LinkedModeUITarget target= null;
- for (int i= 0; i < fTargets.length; i++) {
- if (fTargets[i].getViewer().getDocument() == newDoc) {
- target= fTargets[i];
+ for (LinkedModeUITarget fTarget : fTargets) {
+ if (fTarget.getViewer().getDocument() == newDoc) {
+ target= fTarget;
break;
}
}
@@ -1003,8 +1002,8 @@ public class LinkedModeUI {
String[] contentTypes= getContentTypes(viewer.getDocument());
if (viewer instanceof ITextViewerExtension2) {
ITextViewerExtension2 vExtension= ((ITextViewerExtension2) viewer);
- for (int i= 0; i < contentTypes.length; i++) {
- vExtension.prependAutoEditStrategy(fAutoEditVetoer, contentTypes[i]);
+ for (String contentType : contentTypes) {
+ vExtension.prependAutoEditStrategy(fAutoEditVetoer, contentType);
}
} else {
Assert.isTrue(false);
@@ -1020,8 +1019,8 @@ public class LinkedModeUI {
String[] contentTypes= getContentTypes(viewer.getDocument());
if (viewer instanceof ITextViewerExtension2) {
ITextViewerExtension2 vExtension= ((ITextViewerExtension2) viewer);
- for (int i= 0; i < contentTypes.length; i++) {
- vExtension.removeAutoEditStrategy(fAutoEditVetoer, contentTypes[i]);
+ for (String contentType : contentTypes) {
+ vExtension.removeAutoEditStrategy(fAutoEditVetoer, contentType);
}
} else {
Assert.isTrue(false);
@@ -1044,8 +1043,8 @@ public class LinkedModeUI {
IDocumentExtension3 ext= (IDocumentExtension3) document;
String[] partitionings= ext.getPartitionings();
Set<String> contentTypes= new HashSet<>(20);
- for (int i= 0; i < partitionings.length; i++) {
- contentTypes.addAll(Arrays.asList(ext.getLegalContentTypes(partitionings[i])));
+ for (String partitioning : partitionings) {
+ contentTypes.addAll(Arrays.asList(ext.getLegalContentTypes(partitioning)));
}
contentTypes.add(IDocument.DEFAULT_CONTENT_TYPE);
return contentTypes.toArray(new String[contentTypes.size()]);
@@ -1123,8 +1122,8 @@ public class LinkedModeUI {
fCurrentTarget.fAnnotationModel.removeAllAnnotations();
disconnect();
- for (int i= 0; i < fTargets.length; i++) {
- LinkedModeUITarget target= fTargets[i];
+ for (LinkedModeUITarget fTarget : fTargets) {
+ LinkedModeUITarget target= fTarget;
ITextViewer viewer= target.getViewer();
if (target.fKeyListener != null) {
((ITextViewerExtension) viewer).removeVerifyKeyListener(target.fKeyListener);
@@ -1150,8 +1149,8 @@ public class LinkedModeUI {
switchPosition(fExitPosition, true, false);
final List<IDocument> docs= new ArrayList<>();
- for (int i= 0; i < fTargets.length; i++) {
- IDocument doc= fTargets[i].getViewer().getDocument();
+ for (LinkedModeUITarget fTarget : fTargets) {
+ IDocument doc= fTarget.getViewer().getDocument();
if (doc != null)
docs.add(doc);
}
@@ -1164,13 +1163,12 @@ public class LinkedModeUI {
if (fExitPosition != null)
fExitPosition.getDocument().removePosition(fExitPosition);
- for (Iterator<IDocument> iter = docs.iterator(); iter.hasNext(); ) {
- IDocument doc= iter.next();
+ for (IDocument doc : docs) {
doc.removePositionUpdater(fPositionUpdater);
boolean uninstallCat= false;
String[] cats= doc.getPositionCategories();
- for (int j= 0; j < cats.length; j++) {
- if (getCategory().equals(cats[j])) {
+ for (String cat : cats) {
+ if (getCategory().equals(cat)) {
uninstallCat= true;
break;
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/link/LinkedPositionAnnotations.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/link/LinkedPositionAnnotations.java
index 297afa7d8..e5de52e9f 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/link/LinkedPositionAnnotations.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/link/LinkedPositionAnnotations.java
@@ -107,8 +107,7 @@ final class LinkedPositionAnnotations extends AnnotationModel {
List<Annotation> toRemove= new ArrayList<>(fGroupAnnotations.values());
Map<Annotation, Position> toAdd= new HashMap<>();
if (positions != null) {
- for (Iterator<Position> iter= positions.iterator(); iter.hasNext();) {
- Position p= iter.next();
+ for (Position p : positions) {
if (fGroupAnnotations.containsKey(p)) {
toRemove.remove(fGroupAnnotations.get(p));
} else {
@@ -141,8 +140,7 @@ final class LinkedPositionAnnotations extends AnnotationModel {
List<Annotation> toRemove= new ArrayList<>(fTargetAnnotations.values());
Map<Annotation, Position> toAdd= new HashMap<>();
if (positions != null) {
- for (Iterator<Position> iter= positions.iterator(); iter.hasNext();) {
- Position p= iter.next();
+ for (Position p : positions) {
if (fTargetAnnotations.containsKey(p)) {
toRemove.remove(fTargetAnnotations.get(p));
} else {
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/link/TabStopIterator.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/link/TabStopIterator.java
index bfcdaea89..9ab81f37a 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/link/TabStopIterator.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/link/TabStopIterator.java
@@ -13,7 +13,6 @@ package org.eclipse.jface.text.link;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
-import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;
@@ -105,8 +104,7 @@ class TabStopIterator {
// find the position that follows closest to the current position
LinkedPosition found= null;
- for (Iterator<LinkedPosition> it= fList.iterator(); it.hasNext(); ) {
- LinkedPosition p= it.next();
+ for (LinkedPosition p : fList) {
if (p.offset > current.offset)
if (found == null || found.offset > p.offset)
found= p;
@@ -155,8 +153,7 @@ class TabStopIterator {
// find the position that follows closest to the current position
LinkedPosition found= null;
- for (Iterator<LinkedPosition> it= fList.iterator(); it.hasNext(); ) {
- LinkedPosition p= it.next();
+ for (LinkedPosition p : fList) {
if (p.offset < current.offset)
if (found == null || found.offset < p.offset)
found= p;
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/PresentationReconciler.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/PresentationReconciler.java
index d8b1922f3..be5cd4ae7 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/PresentationReconciler.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/PresentationReconciler.java
@@ -427,8 +427,7 @@ public class PresentationReconciler implements IPresentationReconciler, IPresent
TextPresentation presentation= new TextPresentation(damage, 1000);
ITypedRegion[] partitioning= TextUtilities.computePartitioning(document, getDocumentPartitioning(), damage.getOffset(), damage.getLength(), false);
- for (int i= 0; i < partitioning.length; i++) {
- ITypedRegion r= partitioning[i];
+ for (ITypedRegion r : partitioning) {
IPresentationRepairer repairer= getRepairer(r.getType());
if (repairer != null)
repairer.createPresentation(presentation, r);
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/Reconciler.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/Reconciler.java
index 39ba8881c..409ef0921 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/Reconciler.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/Reconciler.java
@@ -135,8 +135,7 @@ public class Reconciler extends AbstractReconciler implements IReconcilerExtensi
ITypedRegion[] regions= computePartitioning(region.getOffset(), region.getLength());
- for (int i= 0; i < regions.length; i++) {
- ITypedRegion r= regions[i];
+ for (ITypedRegion r : regions) {
IReconcilingStrategy s= getReconcilingStrategy(r.getType());
if (s == null)
continue;
@@ -179,8 +178,8 @@ public class Reconciler extends AbstractReconciler implements IReconcilerExtensi
protected void initialProcess() {
ITypedRegion[] regions= computePartitioning(0, getDocument().getLength());
List<String> contentTypes= new ArrayList<>(regions.length);
- for (int i= 0; i < regions.length; i++) {
- String contentType= regions[i].getType();
+ for (ITypedRegion region : regions) {
+ String contentType= region.getType();
if( contentTypes.contains(contentType))
continue;
contentTypes.add(contentType);
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/revisions/Revision.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/revisions/Revision.java
index 9a69d5264..9fcc83a6a 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/revisions/Revision.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/revisions/Revision.java
@@ -13,14 +13,12 @@ package org.eclipse.jface.text.revisions;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
-import java.util.Iterator;
import java.util.List;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.jface.internal.text.revisions.ChangeRegion;
import org.eclipse.jface.internal.text.revisions.Hunk;
-import org.eclipse.jface.internal.text.revisions.Range;
import org.eclipse.jface.text.IInformationControlCreator;
import org.eclipse.jface.text.source.ILineRange;
@@ -71,10 +69,8 @@ public abstract class Revision {
public final List<RevisionRange> getRegions() {
if (fRanges == null) {
List<RevisionRange> ranges= new ArrayList<>(fChangeRegions.size());
- for (Iterator<ChangeRegion> it= fChangeRegions.iterator(); it.hasNext();) {
- ChangeRegion region= it.next();
- for (Iterator<Range> inner= region.getAdjustedRanges().iterator(); inner.hasNext();) {
- ILineRange range= inner.next();
+ for (ChangeRegion region : fChangeRegions) {
+ for (ILineRange range : region.getAdjustedRanges()) {
ranges.add(new RevisionRange(this, range));
}
}
@@ -92,11 +88,9 @@ public abstract class Revision {
*/
final void applyDiff(Hunk[] hunks) {
fRanges= null; // mark for recomputation
- for (Iterator<ChangeRegion> regions= fChangeRegions.iterator(); regions.hasNext();) {
- ChangeRegion region= regions.next();
+ for (ChangeRegion region : fChangeRegions) {
region.clearDiff();
- for (int i= 0; i < hunks.length; i++) {
- Hunk hunk= hunks[i];
+ for (Hunk hunk : hunks) {
region.adjustTo(hunk);
}
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/revisions/RevisionInformation.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/revisions/RevisionInformation.java
index 0988ab60f..532ba8133 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/revisions/RevisionInformation.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/revisions/RevisionInformation.java
@@ -12,7 +12,6 @@ package org.eclipse.jface.text.revisions;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.Iterator;
import java.util.List;
import org.eclipse.core.runtime.Assert;
@@ -97,8 +96,7 @@ public final class RevisionInformation implements ITextHoverExtension, IInformat
public List<RevisionRange> getRanges() {
if (fRanges == null) {
List<RevisionRange> ranges= new ArrayList<>(fRevisions.size() * 2); // wild size guess
- for (Iterator<Revision> it= fRevisions.iterator(); it.hasNext();) {
- Revision revision= it.next();
+ for (Revision revision : fRevisions) {
ranges.addAll(revision.getRegions());
}
@@ -121,8 +119,8 @@ public final class RevisionInformation implements ITextHoverExtension, IInformat
*/
public void applyDiff(Hunk[] hunks) {
fRanges= null; // mark for recomputation
- for (Iterator<Revision> revisions= getRevisions().iterator(); revisions.hasNext();)
- revisions.next().applyDiff(hunks);
+ for (Revision revision : getRevisions())
+ revision.applyDiff(hunks);
}
@Override
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/PatternRule.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/PatternRule.java
index 4f8cf9412..9aecfeffb 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/PatternRule.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/PatternRule.java
@@ -239,8 +239,8 @@ public class PatternRule implements IPredicateRule {
// Skip escaped character(s)
if (fEscapeContinuesLine) {
c= scanner.read();
- for (int i= 0; i < fSortedLineDelimiters.length; i++) {
- if (c == fSortedLineDelimiters[i][0] && sequenceDetected(scanner, fSortedLineDelimiters[i], fBreaksOnEOF))
+ for (char[] fSortedLineDelimiter : fSortedLineDelimiters) {
+ if (c == fSortedLineDelimiter[0] && sequenceDetected(scanner, fSortedLineDelimiter, fBreaksOnEOF))
break;
}
} else
@@ -252,8 +252,8 @@ public class PatternRule implements IPredicateRule {
return true;
} else if (fBreaksOnEOL) {
// Check for end of line since it can be used to terminate the pattern.
- for (int i= 0; i < fSortedLineDelimiters.length; i++) {
- if (c == fSortedLineDelimiters[i][0] && sequenceDetected(scanner, fSortedLineDelimiters[i], fBreaksOnEOF))
+ for (char[] fSortedLineDelimiter : fSortedLineDelimiters) {
+ if (c == fSortedLineDelimiter[0] && sequenceDetected(scanner, fSortedLineDelimiter, fBreaksOnEOF))
return true;
}
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/RuleBasedPartitionScanner.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/RuleBasedPartitionScanner.java
index 1bb0c91f3..ce0544774 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/RuleBasedPartitionScanner.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/RuleBasedPartitionScanner.java
@@ -96,8 +96,8 @@ public class RuleBasedPartitionScanner extends BufferedRuleBasedScanner implemen
IPredicateRule rule;
IToken token;
- for (int i= 0; i < fRules.length; i++) {
- rule= (IPredicateRule) fRules[i];
+ for (IRule fRule : fRules) {
+ rule= (IPredicateRule) fRule;
token= rule.getSuccessToken();
if (fContentType.equals(token.getData())) {
token= rule.evaluate(this, resume);
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/RuleBasedPartitioner.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/RuleBasedPartitioner.java
index 2d0303f36..f4a03031f 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/RuleBasedPartitioner.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/RuleBasedPartitioner.java
@@ -265,8 +265,8 @@ public class RuleBasedPartitioner implements IDocumentPartitioner, IDocumentPart
(p.getOffset() + p.getLength() == fPreviousDocumentLength)));
fPositionUpdater.update(e);
- for (int i= 0; i < category.length; i++) {
- p= category[i];
+ for (Position element : category) {
+ p= element;
if (p.isDeleted) {
rememberDeletedOffset(e.getOffset());
break;
@@ -479,8 +479,8 @@ public class RuleBasedPartitioner implements IDocumentPartitioner, IDocumentPart
*/
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;
}
}
@@ -540,9 +540,9 @@ public class RuleBasedPartitioner implements IDocumentPartitioner, IDocumentPart
int start, end, gapOffset;
Position gap= null;
- for (int i= 0; i < category.length; i++) {
+ for (Position element : category) {
- current= (TypedPosition) category[i];
+ current= (TypedPosition) element;
gapOffset= (previous != null) ? previous.getOffset() + previous.getLength() : 0;
gap= new Position(gapOffset, current.getOffset() - gapOffset);
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/RuleBasedScanner.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/RuleBasedScanner.java
index efe9ab4d5..83341b0bd 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/RuleBasedScanner.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/RuleBasedScanner.java
@@ -158,8 +158,8 @@ public class RuleBasedScanner implements ICharacterScanner, ITokenScanner {
fColumn= UNDEFINED;
if (fRules != null) {
- for (int i= 0; i < fRules.length; i++) {
- IToken token= (fRules[i].evaluate(this));
+ for (IRule fRule : fRules) {
+ IToken token= (fRule.evaluate(this));
if (!token.isUndefined())
return token;
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/OverviewRuler.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/OverviewRuler.java
index 763054ef5..b85763639 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/OverviewRuler.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/OverviewRuler.java
@@ -747,19 +747,17 @@ public class OverviewRuler implements IOverviewRulerExtension, IOverviewRuler {
WidgetInfos infos= null;
- for (Iterator<Object> iterator= fAnnotationsSortedByLayer.iterator(); iterator.hasNext();) {
- Object annotationType= iterator.next();
-
+ for (Object annotationType : fAnnotationsSortedByLayer) {
if (skip(annotationType))
continue;
int[] style= new int[] { FilterIterator.PERSISTENT, FilterIterator.TEMPORARY };
- for (int t=0; t < style.length; t++) {
+ for (int element : style) {
boolean areColorsComputed= false;
Color fill= null;
Color stroke= null;
- Iterator<Annotation> e= new FilterIterator(annotationType, style[t], fCachedAnnotations.iterator());
+ Iterator<Annotation> e= new FilterIterator(annotationType, element, fCachedAnnotations.iterator());
while (e.hasNext()) {
Annotation a= e.next();
Position p= fModel.getPosition(a);
@@ -811,8 +809,8 @@ public class OverviewRuler implements IOverviewRulerExtension, IOverviewRuler {
fAnnotationHeight= hh;
if (!areColorsComputed) {
- stroke= getStrokeColor(annotationType, style[t] == FilterIterator.TEMPORARY);
- fill= fUseSaturatedColors ? stroke : getFillColor(annotationType, style[t] == FilterIterator.TEMPORARY);
+ stroke= getStrokeColor(annotationType, element == FilterIterator.TEMPORARY);
+ fill= fUseSaturatedColors ? stroke : getFillColor(annotationType, element == FilterIterator.TEMPORARY);
areColorsComputed= true;
}
@@ -1361,8 +1359,8 @@ public class OverviewRuler implements IOverviewRulerExtension, IOverviewRuler {
IAnnotationAccessExtension extension= (IAnnotationAccessExtension) fAnnotationAccess;
Object[] superTypes= extension.getSupertypes(annotationType);
if (superTypes != null) {
- for (int i= 0; i < superTypes.length; i++) {
- color= fAnnotationTypes2Colors.get(superTypes[i]);
+ for (Object superType : superTypes) {
+ color= fAnnotationTypes2Colors.get(superType);
if (color != null)
return color;
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/SourceViewer.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/SourceViewer.java
index b091fbd6c..c1eda300c 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/SourceViewer.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/SourceViewer.java
@@ -502,17 +502,14 @@ public class SourceViewer extends TextViewer implements ISourceViewer, ISourceVi
// install content type specific plug-ins
String[] types= configuration.getConfiguredContentTypes(this);
- for (int i= 0; i < types.length; i++) {
-
- String t= types[i];
+ for (String t : types) {
setAutoEditStrategies(configuration.getAutoEditStrategies(this, t), t);
setTextDoubleClickStrategy(configuration.getDoubleClickStrategy(this, t), t);
int[] stateMasks= configuration.getConfiguredTextHoverStateMasks(this, t);
if (stateMasks != null) {
- for (int j= 0; j < stateMasks.length; j++) {
- int stateMask= stateMasks[j];
+ for (int stateMask : stateMasks) {
setTextHover(configuration.getTextHover(this, t, stateMask), t, stateMask);
}
} else {
@@ -1039,9 +1036,9 @@ public class SourceViewer extends TextViewer implements ISourceViewer, ISourceVi
ISlaveDocumentManagerExtension extension= (ISlaveDocumentManagerExtension) manager;
IDocument[] slaves= extension.getSlaveDocuments(masterDocument);
if (slaves != null) {
- for (int i= 0; i < slaves.length; i++) {
- if (slaves[i] instanceof ChildDocument) {
- ChildDocument child= (ChildDocument) slaves[i];
+ for (IDocument slave : slaves) {
+ if (slave instanceof ChildDocument) {
+ ChildDocument child= (ChildDocument) slave;
Position p= child.getParentDocumentRange();
try {
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/TemplateCompletionProcessor.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/TemplateCompletionProcessor.java
index 4fd70687c..8a8b4f862 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/TemplateCompletionProcessor.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/TemplateCompletionProcessor.java
@@ -69,8 +69,7 @@ public abstract class TemplateCompletionProcessor implements IContentAssistProce
Template[] templates= getTemplates(context.getContextType().getId());
List<ICompletionProposal> matches= new ArrayList<>();
- for (int i= 0; i < templates.length; i++) {
- Template template= templates[i];
+ for (Template template : templates) {
try {
context.getContextType().validate(template.getPattern());
} catch (TemplateException e) {
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplateReaderWriter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplateReaderWriter.java
index 4bd27a2f9..b3e8306e5 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplateReaderWriter.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplateReaderWriter.java
@@ -267,8 +267,7 @@ public class TemplateReaderWriter {
Node root= document.createElement(TEMPLATE_ROOT);
document.appendChild(root);
- for (int i= 0; i < templates.length; i++) {
- TemplatePersistenceData data= templates[i];
+ for (TemplatePersistenceData data : templates) {
Template template= data.getTemplate();
Node node= document.createElement(TEMPLATE_ELEMENT);
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplateStore.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplateStore.java
index 631955a5b..0d76668a9 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplateStore.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplateStore.java
@@ -15,7 +15,6 @@ import java.io.Reader;
import java.io.StringReader;
import java.io.StringWriter;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import org.eclipse.core.runtime.Assert;
@@ -185,9 +184,8 @@ public class TemplateStore {
if (!data.isCustom()) {
// check if the added template is not a duplicate id
String id= data.getId();
- for (Iterator<TemplatePersistenceData> it= fTemplates.iterator(); it.hasNext();) {
- TemplatePersistenceData d2= it.next();
- if (d2.getId() != null && d2.getId().equals(id))
+ for (TemplatePersistenceData persistenceData : fTemplates) {
+ if (persistenceData.getId() != null && persistenceData.getId().equals(id))
return;
}
fTemplates.add(data);
@@ -201,8 +199,7 @@ public class TemplateStore {
*/
public void save() throws IOException {
ArrayList<TemplatePersistenceData> custom= new ArrayList<>();
- for (Iterator<TemplatePersistenceData> it= fTemplates.iterator(); it.hasNext();) {
- TemplatePersistenceData data= it.next();
+ for (TemplatePersistenceData data : fTemplates) {
if (data.isCustom() && !(data.isUserAdded() && data.isDeleted())) // don't save deleted user-added templates
custom.add(data);
}
@@ -234,12 +231,11 @@ public class TemplateStore {
if (data.isUserAdded()) {
fTemplates.add(data);
} else {
- for (Iterator<TemplatePersistenceData> it= fTemplates.iterator(); it.hasNext();) {
- TemplatePersistenceData d2= it.next();
- if (d2.getId() != null && d2.getId().equals(data.getId())) {
- d2.setTemplate(data.getTemplate());
- d2.setDeleted(data.isDeleted());
- d2.setEnabled(data.isEnabled());
+ for (TemplatePersistenceData persistenceData : fTemplates) {
+ if (persistenceData.getId() != null && persistenceData.getId().equals(data.getId())) {
+ persistenceData.setTemplate(data.getTemplate());
+ persistenceData.setDeleted(data.isDeleted());
+ persistenceData.setEnabled(data.isEnabled());
return;
}
}
@@ -268,8 +264,7 @@ public class TemplateStore {
* Restores all contributed templates that have been deleted.
*/
public void restoreDeleted() {
- for (Iterator<TemplatePersistenceData> it= fTemplates.iterator(); it.hasNext();) {
- TemplatePersistenceData data= it.next();
+ for (TemplatePersistenceData data : fTemplates) {
if (data.isDeleted())
data.setDeleted(false);
}
@@ -337,8 +332,7 @@ public class TemplateStore {
*/
public Template[] getTemplates(String contextTypeId) {
List<Template> templates= new ArrayList<>();
- for (Iterator<TemplatePersistenceData> it= fTemplates.iterator(); it.hasNext();) {
- TemplatePersistenceData data= it.next();
+ for (TemplatePersistenceData data : fTemplates) {
if (data.isEnabled() && !data.isDeleted() && (contextTypeId == null || contextTypeId.equals(data.getTemplate().getContextTypeId())))
templates.add(data.getTemplate());
}
@@ -366,8 +360,7 @@ public class TemplateStore {
public Template findTemplate(String name, String contextTypeId) {
Assert.isNotNull(name);
- for (Iterator<TemplatePersistenceData> it= fTemplates.iterator(); it.hasNext();) {
- TemplatePersistenceData data= it.next();
+ for (TemplatePersistenceData data : fTemplates) {
Template template= data.getTemplate();
if (data.isEnabled() && !data.isDeleted()
&& (contextTypeId == null || contextTypeId.equals(template.getContextTypeId()))
@@ -401,8 +394,7 @@ public class TemplateStore {
*/
public TemplatePersistenceData[] getTemplateData(boolean includeDeleted) {
List<TemplatePersistenceData> datas= new ArrayList<>();
- for (Iterator<TemplatePersistenceData> it= fTemplates.iterator(); it.hasNext();) {
- TemplatePersistenceData data= it.next();
+ for (TemplatePersistenceData data : fTemplates) {
if (includeDeleted || !data.isDeleted())
datas.add(data);
}
@@ -420,8 +412,7 @@ public class TemplateStore {
*/
public TemplatePersistenceData getTemplateData(String id) {
Assert.isNotNull(id);
- for (Iterator<TemplatePersistenceData> it= fTemplates.iterator(); it.hasNext();) {
- TemplatePersistenceData data= it.next();
+ for (TemplatePersistenceData data : fTemplates) {
if (id.equals(data.getId()))
return data;
}
@@ -435,8 +426,7 @@ public class TemplateStore {
Reader input= new StringReader(pref);
TemplateReaderWriter reader= new TemplateReaderWriter();
TemplatePersistenceData[] datas= reader.read(input);
- for (int i= 0; i < datas.length; i++) {
- TemplatePersistenceData data= datas[i];
+ for (TemplatePersistenceData data : datas) {
add(data);
}
}

Back to the top