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 | |
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')
10 files changed, 59 insertions, 52 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); 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 38c6be651ea..302648441c2 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 @@ -613,10 +613,11 @@ public class ContentAssistant2 implements IContentAssistant, IContentAssistantEx @Override public void verifyKey(VerifyEvent e) { IContentAssistListener2[] listeners= fListeners.clone(); - for (int i= 0; i < listeners.length; i++) { - if (listeners[i] != null) { - if (!listeners[i].verifyKey(e) || !e.doit) + for (IContentAssistListener2 listener : listeners) { + if (listener != null) { + if (!listener.verifyKey(e) || !e.doit) { return; + } } } } 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 a301bbd818f..1d707db8496 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 @@ -804,10 +804,11 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt @Override public void verifyKey(VerifyEvent e) { IContentAssistListener[] listeners= fListeners.clone(); - for (int i= 0; i < listeners.length; i++) { - if (listeners[i] != null) { - if (!listeners[i].verifyKey(e) || !e.doit) + for (IContentAssistListener listener : listeners) { + if (listener != null) { + if (!listener.verifyKey(e) || !e.doit) { break; + } } } if (fAutoAssistListener != null) 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 39e0e673676..46f9e15c531 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 @@ -1126,15 +1126,13 @@ public class LinkedModeUI { viewer.removeTextInputListener(fCloser); } - for (int i= 0; i < fTargets.length; i++) { - - if (fTargets[i].fAnnotationModel != null) { - fTargets[i].fAnnotationModel.removeAllAnnotations(); - fTargets[i].fAnnotationModel.disconnect(fTargets[i].getViewer().getDocument()); - fTargets[i].fAnnotationModel= null; + for (LinkedModeUITarget fTarget : fTargets) { + if (fTarget.fAnnotationModel != null) { + fTarget.fAnnotationModel.removeAllAnnotations(); + fTarget.fAnnotationModel.disconnect(fTarget.getViewer().getDocument()); + fTarget.fAnnotationModel = null; } - - uninstallAnnotationModel(fTargets[i]); + uninstallAnnotationModel(fTarget); } 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 29886829db0..0ac7a836423 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 @@ -275,9 +275,10 @@ public class CompositeRuler implements IVerticalRuler, IVerticalRulerExtension, */ private void addListener(Class<? extends EventListener> clazz, EventListener listener) { Control[] children= getChildren(); - for (int i= 0; i < children.length; i++) { - if (children[i] != null && !children[i].isDisposed()) - addListener(clazz, children[i], listener); + for (Control c : children) { + if (c != null && !c.isDisposed()) { + addListener(clazz, c, listener); + } } ListenerInfo info= new ListenerInfo(); @@ -309,9 +310,10 @@ public class CompositeRuler implements IVerticalRuler, IVerticalRulerExtension, } } - for (int i= 0; i < children.length; i++) { - if (children[i] != null && !children[i].isDisposed()) - removeListener(clazz, children[i], listener); + for (Control c : children) { + if (c != null && !c.isDisposed()) { + removeListener(clazz, c, listener); + } } } 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 41337d81dbb..cce89f88514 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 @@ -376,8 +376,8 @@ public class DefaultCharacterPairMatcher implements ICharacterPairMatcher, IChar } while ((pos1 >= lowerBoundary && !lowerFound) || (pos2 < upperBoundary && !upperFound)) { - for (int i= 0; i < counts.length; i++) { - counts[i][0]= counts[i][1]= 0; + for (int[] count : counts) { + count[0] = count[1] = 0; } outer1: while (pos1 >= lowerBoundary && !lowerFound) { @@ -389,8 +389,8 @@ public class DefaultCharacterPairMatcher implements ICharacterPairMatcher, IChar } else { counts[i / 2][0]++; //end } - for (int j= 0; j < counts.length; j++) { - if (counts[j][0] == -1) { + for (int[] count : counts) { + if (count[0] == -1) { lowerFound= true; break outer1; } @@ -408,8 +408,8 @@ public class DefaultCharacterPairMatcher implements ICharacterPairMatcher, IChar } else { counts[i / 2][1]--; //end } - for (int j= 0; j < counts.length; j++) { - if (counts[j][1] == -1 && counts[j][0] == -1) { + for (int[] count : counts) { + if (count[1] == -1 && count[0] == -1) { upperFound= true; break outer2; } diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/inlined/InlinedAnnotationSupport.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/inlined/InlinedAnnotationSupport.java index cc897c5549a..c74ff5ea951 100644 --- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/inlined/InlinedAnnotationSupport.java +++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/inlined/InlinedAnnotationSupport.java @@ -634,8 +634,8 @@ public class InlinedAnnotationSupport { */ FontData[] getFontData(int style) { FontData[] fontDatas= regularFont.getFontData(); - for (int i= 0; i < fontDatas.length; i++) { - fontDatas[i].setStyle(style); + for (FontData fontData : fontDatas) { + fontData.setStyle(style); } return fontDatas; } |