diff options
author | Carsten Hammer | 2019-05-26 17:58:04 +0000 |
---|---|---|
committer | Alexander Kurtakov | 2019-06-13 18:03:31 +0000 |
commit | 45c0a30d7027df909b78fa167cf3da83488581d9 (patch) | |
tree | d38f0754453da55322ea62a1c2b82dfdca2652ae /org.eclipse.jface.text/projection | |
parent | 8816cdaddd2f38ac3be6e6a70a0e8a683c772d83 (diff) | |
download | eclipse.platform.text-45c0a30d7027df909b78fa167cf3da83488581d9.tar.gz eclipse.platform.text-45c0a30d7027df909b78fa167cf3da83488581d9.tar.xz eclipse.platform.text-45c0a30d7027df909b78fa167cf3da83488581d9.zip |
Use jdk 5 for-each loopI20190614-0330I20190613-1800
Replace simple uses of Iterator with a corresponding for-each loop. Also
add missing braces on loops as necessary.
Change-Id: Ibde37d56a7962f432ed771f4a215f5903161bde0
Signed-off-by: Carsten Hammer <carsten.hammer@t-online.de>
Diffstat (limited to 'org.eclipse.jface.text/projection')
4 files changed, 29 insertions, 24 deletions
diff --git a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionAnnotationModel.java b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionAnnotationModel.java index 3c4717b43e6..422d2442b58 100644 --- a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionAnnotationModel.java +++ b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionAnnotationModel.java @@ -179,8 +179,9 @@ public class ProjectionAnnotationModel extends AnnotationModel { try { replaceAnnotations(deletions, additions, false); if (modifications != null) { - for (int i= 0; i < modifications.length; i++) - modifyAnnotation(modifications[i], false); + for (Annotation modification : modifications) { + modifyAnnotation(modification, false); + } } } catch (BadLocationException x) { } diff --git a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionSummary.java b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionSummary.java index 2d11988e9f3..15bdd8ac944 100644 --- a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionSummary.java +++ b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionSummary.java @@ -290,8 +290,7 @@ class ProjectionSummary { } private boolean includes(IRegion[] regions, Position position) { - for (int i= 0; i < regions.length; i++) { - IRegion region= regions[i]; + for (IRegion region : regions) { if (position != null && !position.isDeleted() && region.getOffset() <= position.getOffset() && position.getOffset() + position.getLength() <= region.getOffset() + region.getLength()) return true; diff --git a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionViewer.java b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionViewer.java index 8babac8495e..403af6398b0 100644 --- a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionViewer.java +++ b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionViewer.java @@ -823,11 +823,13 @@ public class ProjectionViewer extends SourceViewer implements ITextViewerExtensi // collapse contained regions ProjectionAnnotation[] collapsed= computeCollapsedNestedAnnotations(offset, length); if (collapsed != null) { - for (int i= 0; i < collapsed.length; i++) { - IRegion[] regions= computeCollapsedRegions(fProjectionAnnotationModel.getPosition(collapsed[i])); - if (regions != null) - for (int j= 0; j < regions.length; j++) - removeMasterDocumentRange(projection, regions[j].getOffset(), regions[j].getLength()); + for (ProjectionAnnotation c : collapsed) { + IRegion[] regions = computeCollapsedRegions(fProjectionAnnotationModel.getPosition(c)); + if (regions != null) { + for (IRegion region : regions) { + removeMasterDocumentRange(projection, region.getOffset(), region.getLength()); + } + } } } @@ -1047,8 +1049,8 @@ public class ProjectionViewer extends SourceViewer implements ITextViewerExtensi * We pass the removed annotation into this method for performance reasons only. Otherwise, they could be fetch from the event. */ private void processDeletions(AnnotationModelEvent event, Annotation[] removedAnnotations, boolean fireRedraw) throws BadLocationException { - for (int i= 0; i < removedAnnotations.length; i++) { - ProjectionAnnotation annotation= (ProjectionAnnotation) removedAnnotations[i]; + for (Annotation removedAnnotation : removedAnnotations) { + ProjectionAnnotation annotation = (ProjectionAnnotation) removedAnnotation; if (annotation.isCollapsed()) { Position expanded= event.getPositionOfRemovedAnnotation(annotation); expand(expanded.getOffset(), expanded.getLength(), fireRedraw); @@ -1141,8 +1143,8 @@ public class ProjectionViewer extends SourceViewer implements ITextViewerExtensi } private void processChanges(Annotation[] annotations, boolean fireRedraw, List<Position> coverage) throws BadLocationException { - for (int i= 0; i < annotations.length; i++) { - ProjectionAnnotation annotation= (ProjectionAnnotation) annotations[i]; + for (Annotation a : annotations) { + ProjectionAnnotation annotation = (ProjectionAnnotation) a; Position position= fProjectionAnnotationModel.getPosition(annotation); if (position == null) @@ -1152,9 +1154,11 @@ public class ProjectionViewer extends SourceViewer implements ITextViewerExtensi if (annotation.isCollapsed()) { coverage.add(position); IRegion[] regions= computeCollapsedRegions(position); - if (regions != null) - for (int j= 0; j < regions.length; j++) - collapse(regions[j].getOffset(), regions[j].getLength(), fireRedraw); + if (regions != null) { + for (IRegion region : regions) { + collapse(region.getOffset(), region.getLength(), fireRedraw); + } + } } else { expand(position.getOffset(), position.getLength(), fireRedraw); } @@ -1203,8 +1207,9 @@ public class ProjectionViewer extends SourceViewer implements ITextViewerExtensi if (position != null) { IRegion[] regions= computeCollapsedRegions(position); if (regions != null) - for (int i= 0; i < regions.length; i++) - removeMasterDocumentRange(projection, regions[i].getOffset(), regions[i].getLength()); + for (IRegion region : regions) { + removeMasterDocumentRange(projection, region.getOffset(), region.getLength()); + } } } } @@ -1615,12 +1620,11 @@ public class ProjectionViewer extends SourceViewer implements ITextViewerExtensi int widgetSelectionExclusiveEnd= widgetSelection.x + widgetSelection.y; Position[] annotationPositions= computeOverlappingAnnotationPositions(modelSelection); - for (int i= 0; i < annotationPositions.length; i++) { - IRegion[] regions= computeCollapsedRegions(annotationPositions[i]); + for (Position annotationPosition : annotationPositions) { + IRegion[] regions = computeCollapsedRegions(annotationPosition); if (regions == null) continue; - for (int j= 0; j < regions.length; j++) { - IRegion modelRange= regions[j]; + for (IRegion modelRange : regions) { IRegion widgetRange= modelRange2ClosestWidgetRange(modelRange); // only take collapsed ranges, i.e. widget length is 0 if (widgetRange != null && widgetRange.getLength() == 0) { diff --git a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/SourceViewerInformationControl.java b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/SourceViewerInformationControl.java index 06a768f589e..dbd75841353 100644 --- a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/SourceViewerInformationControl.java +++ b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/SourceViewerInformationControl.java @@ -165,8 +165,9 @@ class SourceViewerInformationControl implements IInformationControl, IInformatio fStatusField.setText(statusFieldText); Font font= fStatusField.getFont(); 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); + } fStatusTextFont= new Font(fStatusField.getDisplay(), fontDatas); fStatusField.setFont(fStatusTextFont); GridData gd2= new GridData(GridData.FILL_VERTICAL | GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING); |